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'.
Here is the code:
is obj:object; do obj := .InformationFlow.Variable.createObject(.Models.Frame, 100, 100); end;
Solved! Go to Solution.
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;
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
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.