question

Borja Lorenzo avatar image
0 Likes"
Borja Lorenzo asked Borja Lorenzo commented

How to set and get value from a Gobal Variable

Hello,

I have a question about how to assign a value to and retrieve the value from a global variable.

From a GUI, I select a value and through the onSelect attribute, I intend to assign this value to a global variable. The global variable is defined as a string named EstadoSimular.

The code I am trying to define does not manage to return the value of the global variable. I am not sure if I am not assigning it correctly in the setvarstr or if I am not able to capture it properly for the print.


Attached is an image showing all the related elements.

1728292196418.png

Thanks in advance for your help.

FlexSim 24.1.1
guiglobalvariablegetvarstsetvarstr
1728292196418.png (125.7 KiB)
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

1 Answer

Marcello Rosadini avatar image
0 Likes"
Marcello Rosadini answered Borja Lorenzo commented

Hi Borja,

you can read/write a Global Variable just buy using its name:

EstadoSimular = "aaa";

print(EstadoSimular);

would print aaa in the Output console


· 1
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Borja Lorenzo avatar image Borja Lorenzo commented ·
Thanks Marcello.

It works.

0 Likes 0 ·