GlobalVar on Crane

All topics on the Atoms in any Enterprise Dynamics Library.
Post Reply
John
Posts: 5
Joined: Saturday 31 May, 2014 - 11:39

GlobalVar on Crane

Post by John »

Hello,
I have a problem regarding a portal crane:
I use a global variable for the send-to-function on a portal crane-atom. This works fine, but when I open the model, I always get the error message "Compile error: "GlobalVarName" is not a valid expression. Reference: ... ".

I think that the reason for this message is, that the globalvar is defined on trigger-on creation a Source-Atom. In the model-tree, the crane is on a higher position than the source-atom and therefore, I guess, is loaded earlier. I tried to move the crane down in the model tree, but every time I open the model again, it is again on top.

So, is there a way to move the crane down in the model tree=
Or should I define my globalvar on a different atom?

Thanks in advance for yout help!!

Best regards

John
Nick
Posts: 48
Joined: Saturday 15 February, 2014 - 01:52

Re: GlobalVar on Crane

Post by Nick »

Hi John,

Your thoughts are right: the source atom tries to acces the variable. However, the variable is not yet declared due to the loading sequence. Also, The position of the portal crane is set to 1 on Reset. In the Atom Editor (Shift + F5), tab Events, Reset you will find the following code:

Code: Select all

do(
 SetRank(1, c),
 {...}
)
Both proposed solutions are possible:
1. Set the rank of the portal crane to 2 to move the crane down in the model tree. Set the rank of the source atom to 1.
2. Declare the global variable you use for the Source atom on the OnInit of the Portal Crane (first atom in your model). You only need to declare the variable itself: Dim([MyVar],VbValue); You can declare the variable with its corresponding value again later on in your model.

Regards, Nick
John
Posts: 5
Joined: Saturday 31 May, 2014 - 11:39

Re: GlobalVar on Crane

Post by John »

Great! It works! Thank you for the information!
Post Reply