Setup a table of desired size in a Condition Control Atom

All topics on coding 4Dscript in Enterprise Dynamics.
Post Reply
CyrusMMXI
Posts: 9
Joined: Friday 04 November, 2011 - 11:51

Setup a table of desired size in a Condition Control Atom

Post by CyrusMMXI »

Every atom including Condition Control has a table embedded in it. I would like to set the number of columns and rows of a Condition Control Atom in my model based on the number of its input channels. The code I put in the Init event of Condition Control is as below,

Code: Select all

do(
nRows(c):=nric,
nCols(c):=nric)


Unfortunately it doesn't work! How the code should be modified? Which event fits this end best?
MarvinH
Posts: 93
Joined: Tuesday 25 January, 2011 - 11:07
Contact:

Re: Setup a table of desired size in a Condition Control Ato

Post by MarvinH »

Hello!

The update of the number of rows fails because (at the time the code is executed) the number of columns equals zero. Because the first update fails, the second update fails for the same reason.

Try using the following:

Code: Select all

SetTable(
  NrIc(c),
  NrIc(c),
  c
)
For more info about the function and parameters, please refer to the Help file.

Good luck!

Marvin
CyrusMMXI
Posts: 9
Joined: Friday 04 November, 2011 - 11:51

Re: Setup a table of desired size in a Condition Control Ato

Post by CyrusMMXI »

Thanks Marvin! Now I have another problem!
I want to show the table to the user as the user right clicks my Condition Control atom in which I have defined the table!
What is your suggestion here? How can I show the table as a new tab in that parameters window?
MarvinH
Posts: 93
Joined: Tuesday 25 January, 2011 - 11:07
Contact:

Re: Setup a table of desired size in a Condition Control Ato

Post by MarvinH »

Hello!

I don't know how experienced you are, but modifying GUI's is quite a challenge.

Maybe you can have a look at Drawing table information?

Another solution is to change the OnUser event of the Condition Control. You could make an script as follows:

Code: Select all

If(
  DoubleClick,
  { * User double clicks the atom, execute the original code (i.e. show the GUI) * }
  Inherit,
  { * User right clicks the atom, show the table * }
  EditTable(c)
)
The advantage of the first solution is that the user can only view the data and not edit it. In case you want the user to be able to change the data, the second solution would be better.

Good luck!

Marvin
Post Reply