Cancel
Showing results for 
Search instead for 
Did you mean: 

create a Variable object in simTalk

Experimenter
Experimenter

Hi,

I am trying to create a Variable object through simTalk.

I used the usual createObject(.Models.Frame, xpos, ypos, name).

Nevertheless, although it works for other classes of object, it is not working for the Variable object.

The error code says that an 'integer' cannot accept the method 'createObject'.

Any suggestions?

Thank you

 

Here is the code:

 

is 
	obj:object; 
do 
	obj := .InformationFlow.Variable.createObject(.Models.Frame, 100, 100);
end;
2 REPLIES

Betreff: create a Variable object in simTalk

Gears Phenom Gears Phenom
Gears Phenom

You need to use the REF-operator when you want an object-reference on a variable (or method) instead of its (return) value, like this:

is 
	obj:object; 
do 
	obj := ref(.InformationFlow.Variable).createObject(.Models.Frame, 100, 100);
end;

Smiley Happy

____________________________________________________________
Alex Dilg, Consultant at SimPlan AG (www.SimPlan.de)
This post was good and/or helpful to you? Please provide some Kudos, thank you!

Re: create a Variable object in simTalk

Siemens Phenom Siemens Phenom
Siemens Phenom

Hello,

 

in case that you want to create a variable using simtalk which is accessible by all methods within a frame you could also use this

 

root.createAttr("MyCustomVariable", "object") 

This creates an attribute for your frame which any other method within that frame can access, making this a "global variable" which won`t be visible inside of your model. 

 

Kind regards,

Igor
------------------------------------------------------------------------------------------------------
Did you like the answer? Then click the Thumbs Up button.
Did the answer solve your problem? Then accept the answer as solution