PDA

View Full Version : Global arrays declared with no o f elements only


RalfGruber
09-02-2008, 01:02 PM
Hi,

after I just used a global integer array with 55 elements and had to press 55 times the button to add an element and had to fill in an initial value 55 times, Iīm going to post this suggestion:
Canīt we have an alternative way to declare a global array with just the number of elements we like and have the initial values optional?
I think that would save much time since initializing an array with a loop is much more comfortable than filling each value manually.

Thanks

Ralf aka Ralle
Felxsim Germany

Phil BoBo
09-02-2008, 01:58 PM
If you want to initialize your array using a loop in code instead of manually in the GUI, you can just look at the code for the Add button and steal it. (By using the right click option View > Explore Structure.)

treenode arraylist = node("/1/GlobalVariables/variable1/3",model());

for(int r=1;r<=55;r++)
{
nodeinsertinto(arraylist);
nodeadddata(last(arraylist),DATATYPE_STRING);
setnodestr(last(arraylist),"1234");
}


Anything that any GUI does in Flexsim is visible to the user to take that code and put it to work in whatever way you need.

RalfGruber
09-12-2008, 10:05 AM
Phil,

of course, you are right, but this is the experienced user solution. I thought the global variables GUI was created to help less or none experienced users so I still like the idea to have another editfield were you just have to put in the number of elements for an array you want to create.

Tanks

Ralf aka ralle