Userobj
Userobj (user-defined object).
User Object Declaration
userobj declare an empty, unregistered user object.
A simple, non-registered, user object is created by simply using the userobj command followed by the name of the user object:
userobj myuserobject
User Object Views
Although a registered user object may have user-defined views available, all user objects have the following built-in views.
display display table, graph, or spool output in the user object window.
label display or change the label view of a user object.
members display a list of the members of a user object.
User Object Procs
Although a registered user object may have user-defined procs available, all user objects have the following built-in procs.
add add a data or object member to the user object.
clear remove all members from the user object.
clearhist clear the contents of the history attribute.
copy creates a copy of the user object.
drop drop a data or object member from the user object.
extract display or copy a data member from the user object.
label display or change the label view of a user object.
olepush push updates to OLE linked objects in open applications.
setattr set the value of an object attribute.
User Object Data Members
Although user objects can have user-defined data members, the following built-in data members also exist for all user objects.
String values
@attr("arg") string containing the value of the arg attribute, where the argument is specified as a quoted string.
@description string containing the user object’s description (if available).
@detailedtype string with the object type: “USEROBJ”.
@displayname string containing the user object’s display name. If the user object has no display name set, the name is returned.
@members space delimited list of all the user-defined members currently stored inside the user object.
@name string containing the user object’s name.
@remarks string containing the user object’s remarks (if available).
@type string with the object type: “USEROBJ”.
@updatetime string representation of the time and date at which the user object was last updated.
Scalar values
@hasmember(“name”) returns a 1 or a 0 depending on whether the user object has a data member called name.
Add a data or object member to the user object.
Adds a new data or object member to the user object. You may either create a new string or scalar member directly, or copy an existing object from the current workfile page. Note that only view objects (tables, graphs, text objects or spools) or matrix objects can be copied to a user object as members.
Syntax
userobject_name.add(options) member arg
userobject_name.add(options) [member] objname
If creating a new member inside the user object, you should specify the name of the member with member, and then specify its value with arg. If arg is a number, the new member will be created as a scalar, if arg is a string, the new member will be a string.
If copying the member from the current workfile page, you should use objname to specify the name of the object in the workfile you wish to copy. If you would like to give the member a different name inside the user object, you can specify that name with member.
Options
r | Replace an existing member. If this option is not used, and a member with the same name already exists, EViews will error. |
d | When copying an object from the workfile page as the data member, delete the object from the workfile after copying. |
Examples
myobj.add mymember 3
Creates a new member inside the user object MYOBJ called MYMEMBER, and sets its value equal to 3.
myobj.add(r) mymember "hello"
Replaces the member MYMEMBER with a string value of “hello”.
myobj.add matv
Creates a new member called MATV by copying the existing workfile object MATV into the user object.
myobj.add(d) mymat matm
Creates a new member called MYMAT by copying the workfile object MATM into the user object. MATM is deleted from the workfile.
Cross-references
See
“User Objects” for discussion of user objects.
Removes all members from the user object.
Syntax
userobject_name.clear
Examples
myuserobj.clear
Deletes all members from the user object MYUSEROBJ.
Cross-references
See
“User Objects” for discussion of user objects.
Clear the contents of the history attribute.
Removes the user object’s history attribute, as shown in the label view of the user object.
Syntax
userobj_name.clearhist
Examples
u1.clearhist
u1.label
The first line removes the history from the user object U1, and the second line displays the label view of U1, including the now blank history field.
Cross-references
See
“Labeling Objects” for a discussion of labels and display names.
Clear the contents of the remarks attribute.
Removes the user object’s remarks attribute, as shown in the label view of the user object.
Syntax
userobj_name.clearremarks
Examples
u1.clearremarks
u1.label
The first line removes the remarks from the user object U1, and the second line displays the label view of U1, including the now blank remarks field.
Cross-references
See
“Labeling Objects” for a discussion of labels and display names.
Creates a copy of the userobj.
Creates either a named or unnamed copy of the user object.
Syntax
userobj_name.copy
userobj_name.copy dest_name
Examples
u1.copy
creates an unnamed copy of the user object U1.
u1.copy u2
creates U2, a copy of the user object U1.
Cross-references
Display table, graph, or spool output in the user object window.
Display the contents of a table, graph, or spool in the window of the user object.
Syntax
userobject_name.display object_name
Examples
uo1.display tab1
Display the contents of the table TAB1 in the window of the object UO1.
Cross-references
Display name for user objects.
Attaches a display name to a user object.
Syntax
userobject_name.displayname display_name
Display names are case-sensitive, and may contain a variety of characters, such as spaces, that are not allowed in user object object names.
Examples
hrs.displayname Hours Worked
hrs.label
The first line attaches a display name “Hours Worked” to the user object HRS, and the second line displays the label view of HRS, including its display name.
Cross-references
See
“Labeling Objects” for a discussion of labels and display names.
Removes a member from the user object.
Syntax
userobject_name.drop member
Removes the member member from the user object.
Examples
myuserobj.drop mymember
Deletes the member MYMEMBER from the user object MYUSEROBJ.
Cross-references
See
“User Objects” for discussion of user objects.
Displays or copies a member from the user object.
Syntax
userobject_name.extract member [wfname]
Copies the data member specified by member into the current workfile page. If wfname is not specified, a new untitled object will be created, allowing you to quickly inspect the contents of the data member. If wfname is given, a new object in the workfile will be created with a name equal to wfname..
Examples
myuserobj.extract mymember
copies the data member MYMEMBER as a new untitled object in the workfile.
myuserobj.extract mymember xx
copies the data member MYMEMBER as a new object in the workfile called XX.
Cross-references
See
“User Objects” for discussion of user objects.
Display or change the label view of a user object, including the last modified date and display name (if any).
As a procedure, label changes the fields in the user object label.
Syntax
userobject_name.label
userobject_name.label(options) [text]
Options
The first version of the command displays the label view of the user object. The second version may be used to modify the label. Specify one of the following options along with optional text. If there is no text provided, the specified field will be cleared.
c | Clears all text fields in the label. |
d | Sets the description field to text. |
s | Sets the source field to text. |
u | Sets the units field to text. |
r | Appends text to the remarks field as an additional line. |
p | Print the label view. |
Examples
The following lines replace the remarks field of user object UO1 with “Data from CPS 1988 March File”:
UO1.label(r)
UO1.label(r) Data from CPS 1988 March File
To append additional remarks to UO1, and then to print the label view:
uo1.label(r) Log of hourly wage
uo1.label(p)
To clear and then set the units field, use:
uo1.label(u) Millions of bushels
Cross-references
See
“Labeling Objects” for a discussion of labels.
Displays a list of all members currently stored inside the user object.
Syntax
userobject_name.members(options)
Options
p | Print the spreadsheet view. |
Examples
myuserobj.members(p)
displays and prints the members view of user object MYUSEROBJ.
Cross-references
See
“User Objects” for discussion of user objects.
Push updates to OLE linked objects in open applications.
Syntax
userobj_name.olepush
Cross-references
See
“Object Linking and Embedding (OLE)” for a discussion of using OLE with EViews.
Set the object attribute.
Syntax
userobject_name.setattr(attr) attr_value
Sets the attribute attr to attr_value. Note that quoting the arguments may be required. Once added to an object, the attribute may be extracted using the @attr data member.
Examples
a.setattr(revised) never
String s = a.@attr("revised")
sets the “revised” attribute in the object A to the string “never”, and extracts the attribute into the string object S.
Cross-references
Declare an unregistered, empty user object.
The userobj command declares a new empty user object.
Syntax
userobj userobject_name
Examples
userobj uo1
creates a new empty user object called UO1.
Cross-references
See
“User Objects” for discussion of user objects.