Confusing Error at openin a model

All topics specific to modeling questions in Enterprise Dynamics
Post Reply
Al_spyro
Posts: 5
Joined: Tuesday 06 December, 2011 - 17:07

Confusing Error at openin a model

Post by Al_spyro »

Hi Dear Incontrol,
I built 2 models and i have a confusing problem with them. when i open each of these models An error appear's and the model totally goes wrong ! if i want to make it right ,i must reopen it from ED, Then it work's right. Ill appreciate your help with this matter.

Best regards
Alireza Esmati
Attachments
factory railway model.mod
A harbor system
(89.47 KiB) Downloaded 280 times
(Bus station).mod
A bus transit system
(46.55 KiB) Downloaded 292 times
User avatar
MatthijsJongboer
Posts: 200
Joined: Thursday 11 November, 2010 - 14:12

Re: Confusing Error at openin a model

Post by MatthijsJongboer »

Hi Al_spyro,

This is a common problems since Enterprise Dynamics uses the 4Dscript language.
Basically what happens is that a function has its syntax checked before it is implemented.
The model tree has a sequential loading of its atoms. This is also the solution to this problem.
You need to define the functions before they are implemented. This can be best achieved by moving the definition atoms high (rank 1) in the model tree.
For your model bus station model, select the Initialize atom in the modeltree and execute the following code in the interact:

Code: Select all

SetRank(1, TreeAtom)
Refresh the modeltree and you will see it at rank 1 of your model.

The factory railway model is somewhat more complex to solve. The Portal Crane has code on reset that places itself at rank 1 where this is also the atom that has the implementation of the required function.
A way to solve this is to make sure the function (or global variable) is defined before it is used.
So placing the definition in the Oncreation of the Portal Crane is the quickest solution. Your code onCreation of the Portal Crane would then look like this:

Code: Select all

Do(
  Inherit,
  GlobalVar([khoroji],vbValue,1)
)
Al_spyro
Posts: 5
Joined: Tuesday 06 December, 2011 - 17:07

Re: Confusing Error at openin a model

Post by Al_spyro »

Hi MatthijsJongboer,

thank you for your answer, i did what you said and the error dissappear but i must reopen the model to work correctly each time i open the model .

Best regards
Alireza Esmati
User avatar
MatthijsJongboer
Posts: 200
Joined: Thursday 11 November, 2010 - 14:12

Re: Confusing Error at openin a model

Post by MatthijsJongboer »

The bus station model works without any problems.
The factory railway model model has a problem with the sendto strategy.
The variable khoroji (the code I wrote) is then best placed on the OnInit eventhandler.
Post Reply