The create() function creates an instance of a class or an instance with an object handle. The syntax is one of the following:
-
create(<classname>, <objectname>);
-
create(<objhandle>);
If the object being created already exists, the create() function returns a reference to that object or an error if the object exists and belongs to different class.
If you specify an object handle (objhandle) and the object does not exist, the create() function creates the object and the object handle.
You can assign the result of the function to a variable (for example, objRef). This defines an object handle for the object.
objRef = create(<classname>, <objectname>);
The following script example loads instances of ports and cards. The name of the Domain Manager that contains the model is JS1.
ASL Script (create_obj.asl): START { CARD rep(PORT) } CARD { "CARD:" cardname:word eol } do { create("Card",cardname); } PORT { portname:word eol } do { create("Port",portname); } DEFAULT { err:{..eol} } do { print(err." Failed"); } EOF do {print("Complete"); } Input (create_obj.txt): CARD: CARD0 PORT00 PORT01 PORT02 PORT03 CARD: CARD1 PORT10 PORT11 PORT12 CARD: CARD2 PORT20 PORT21 PORT22 PORT23 PORT24 PORT25 Output: $ sm_adapter --server=JS1 --file=create_obj.txt create_obj.asl Complete $