Commands to handle data structures.
MLDesigner supports the definition of complex data types. The difference between MLDesigner data types and the original base types is that you can define arbitrary structure data types as well as certain special data types, such as enumeration, that were not defined by Ptolemy. For more detailed information about the structure and the programming of MLDesigner data types, refer to Programming→Using Data Types
To distinguish between Ptolemy original types and MLDesigner data types, the latter are referred to as "data structures" throughout this document.
Use the command
newds <ds_name> <ds_base>
to create a new data structure of type ds_name derived from the data structure ds_base. Parameter ds_name specifies the type name as well as the library in which the new data structure is stored. Library and data type name are separated by a colon. If the library name is omitted, the new data structure is created in the library of the parent data structure. For example, the command
newds MyLib:MyPacket Root.Packet
creates a data structure in MyLib that is derived from Root.Packet. The unique name of this data structure is then MyLib:Root.Packet.MyPacket.
To create a new member of a data structure, use command
newdsmember <ds_name> <member_name> <member_type> [default] [subrange]
This command creates a new member with name member_name of type member_type in the data structure given by ds_name. It is possible to specify a default value. If the data structure member is of numerical type, a subrange of values can also be defined with open and closed intervals. The complete syntax of this command is
newdsmember <ds_name> <member_name> <member_type>
newdsmember <ds_name> <member_name> <member_type> <default>
newdsmember <ds_name> <member_name> <member_type> <default> '['or'(' <min>,<max> ')'or']'
newdsmember MyLib:Root.Packet.MyPacket Byte1 Root.Integer 0 [0,256)
creates a new member Byte1 in data structure MyLib:Root.Packet.MyPacket which can have values between 0 and 255. (Note the '[' symbol includes the 0 and the ')' symbol excludes 256).
You can use the command
newenum <enum_name> <enum_base>
to create a new enumeration type with name name that is derived from the enumeration type enum_base. Parameter enum_name specifies the enumeration name as well as the library in which the new enumeration type is stored. Library and type name are separated by a colon. If the library name is omitted, the new enumeration type is stored in the library of parent enumeration type. For example
newenum MyLib:MyEnum Root.ENUM
creates an enumeration in MyLib that is derived from Root.ENUM. The unique name of this enumeration type then is MyLib:Root.ENUM.MyEnum. To create a new member of an enumeration, use the command
newenummember <enum_name> <member_value> [member_index]
Using this command, you can create a new enumeration value with string value member_value and an according index member_index. If member index is omitted, the next available index is used. For example
newenummember MyLib:Root.ENUM.MyEnum Member1 0
creates a new enumeration value for MyLib:Root.ENUM.MyEnum with value Member1 and member index 0.
Using the command
deletes the data structure or enumeration type with unique name ds_name. A unique name consists of the library name and the full type name separated by a colon. For example
deletes the MyEnum enumeration type in library MyLib. Using * for parameter ds_name, you can delete all data structures and enumeration types that were created by you.
You can use the command
to list the names of all existing data structure types including data structure types that are defined by the standard type library. Use the command
to print out the default value of a data structure given by the unique name parameter ds_name.