Cancel
Showing results for 
Search instead for 
Did you mean: 

Call a constant value with methods

Hello everyone!

 

My model contains a main frame with multiple sub-frames. In each subframes I am using methods to do some statistical calculations. In these calculations, I am using some constant values.

To save time between all simulations I do, I would like to define the value of every constant I am using in the simulation. Th goal would be to define all my constants somehow/somewhere and then to make each method call the constant value it needs.

It would be like "declaring the constants" at the beginning and then use them every time I want by calling them by their names.

 

Thanks a lot for your help!

 

Cheers,

 

Vincent

 

 

3 REPLIES

Re: Call a constant value with methods

Legend
Legend

You can have a lot of different approaches: if you wanna use global variable you can create a subframe in the main frame called "CostantVariable". Inside this frame you insert every variable you need. Then each code will call the variable like

root.CostantVariable.Variable1

root.CostantVariable.Variable2

root.CostantVariable.Variable3

....

 

I would do something similar creating a tablefile in the root frame instead of a subframe. In the tablefile I would store a variable for each row:

root.TableCostant["Value","Variable1"];

root.TableCostant["Value","Variable2"];

root.TableCostant["Value","Variable3"];

....

 

There a lot of other possibilities, depending by how you write the code you need.

Regards
Alessio

 

Re: Call a constant value with methods

Valued Contributor
Valued Contributor
You can have pointers for each of the variables as suggested by Alessio in a Frame called "Constant Variable", and to save the Input time even more, you could make use of the User Defined Dialogs. Create your own Dialogs for the values you want to set. This way, you do not Need to open each variable and set it or go into the Networks to set the values.

If you Need more Information about the Dialogs and how to Programme them, refer to the Step by Step Help and search for "Dialog". Hope this helps. Smiley Happy

Regards,
Shreyas

Re: Call a constant value with methods

Thanks to you two!

 

It works perfectly and the communication with the user is vers easy!

 

Thanks again?