Injecting code into "entry trigger" from a table

All topics on coding 4Dscript in Enterprise Dynamics.
Post Reply
nfiguera
Posts: 3
Joined: Thursday 26 April, 2012 - 11:35

Injecting code into "entry trigger" from a table

Post by nfiguera »

Hi,

I have an initialization table with the value for different attributes of various server atoms. One attribute I would like to set also from that table is the 4DS code of the "entry trigger" attribute.

It is interesting that when I try to set the attribute to a value it works, but when I define a 4ds code in the table it is not recognize.

Should I be escaping the code in an specific way? or is it a matter of type casting?

Thanks for your help.
marlies
Posts: 301
Joined: Monday 17 January, 2011 - 09:28

Re: Injecting code into "entry trigger" from a table

Post by marlies »

Hi,

To get values from a table use:

Code: Select all

Cell( x,y, refMyTable)
To get text from a table use ( the 3rd parameter is not always required, but will force ED to return the result as text):

Code: Select all

Cell( x,y, refMyTable, 2) 
To execute code defined in a table cell, you need to read the content as a text and then execute that string using:

Code: Select all

Execstring( Cell( x,y, refMyTable, 2))
Tip: when you want to define pieces of code in a central location in the model, it could be better to use the atom Function Editor (it's in the Tools part of the library). It allows you to create your own 4Dscript functions that can be called in any trigger in your model.

Regards,

Marlies
Post Reply