wait statement

All topics on coding 4Dscript in Enterprise Dynamics.
Post Reply
anna
Posts: 2
Joined: Thursday 23 May, 2013 - 11:13

wait statement

Post by anna »

Hi All,

I have the impression, that the wait staement (as well as the waitglobal statement) in Taylor ED does not work:

in the attached modell I call the following script onexit of source2.

do(
wait(
att(8,atombyname([Source2],model))=1,
enterdebugger(1)
)
)

the attribute Nr. 8 ofsource2 has the value 0.

Then I change the value of attribute Nr. 8 of source2 with the 4D Interact-Tools to 1:

setatt(8,1,atombyname([Source2],model))

but the debugger does not open.

Is there a possibility to see, which methods are currently suspended (waiting vor an event to happen??)

I would appreciate any help!!!

Best regards,
Anna
Attachments
Beispielmodell_wait_source_onexit1.mod
(22.11 KiB) Downloaded 235 times
marlies
Posts: 301
Joined: Monday 17 January, 2011 - 09:28

Re: wait statement

Post by marlies »

Hello Anna,

If I test your model, the debugger does pop up. However only when I change the attribute before running. I noticed that you set the parameter number of products of this source to 1. So, during the simulation this source generates only 1 product and the exit trigger will be executed only once as well.

Is there a special reason you did choose to use the wait statement? What kind of test do you want to execute? Maybe you could just use an if statement to check if the debugger should open?

Kind regards, Marlies
anna
Posts: 2
Joined: Thursday 23 May, 2013 - 11:13

Re: wait statement

Post by anna »

Thanks marlies for your answer.

This model is only an example. I need the wait statement in another model to wait for a variable to change. (And not to only ask if it currently has a certain value.)

In the example model the second source keeps on producing atoms, to keep the model running. Source1 only creates 1 atom, because i only want to trigger the wait statement one time.

The debugger only opens once but not within the wait statement after changing the variable.

Does maybe anyone have a model with a wait statement that works? Or is there any other possibility to wait for an event?

I would highly appreciate your help!!!
Anna
marlies
Posts: 301
Joined: Monday 17 January, 2011 - 09:28

Re: wait statement

Post by marlies »

Hi Anna,

I checked with my colleagues and we found out that the 2nd parameter of the wait statement (where you have the enterdebugger) is only executed when the 1st parameter is true at the time you execute the wait statement. I don't think that this statement will give you the required result and would advice to find another method.

You could consider using the user events atom (from the category time) to repeat an event that checks for the value to be true. Both options however will slow down your model as for a 'continues' check you'll have to create the event very often.

I don't know what you need to check exactly, but if it is like the example: wait until an attribute gets a certain value. I think it's better to add some checks at the location in the code where the attribute is updated.

Regards, Marlies
Post Reply