Global Variable

Good Day!

Where is the best place to store a variable that will contain a parameter that starts an executable:
For example:
myremobjectserver.exe -pi

This variable will contain true if executed with -pi or false if nothing is specified.

In service and method implementations, it is necessary to read this variable to make connections to production or test environments accordingly. This should be client-agnostic.

I was thinking of defining a logical global variable in the main form, assigning it true or false depending on whether the executable has this parameter or not.

Make use of the main form in service implementations, and read this variable to proceed accordingly within the function.

This variable will never be rewritten, so I think there would be no problems with concurrent readings.

Is this a correct approach?

Thanks for your advice.

I think a global variable – or a static/class field/property in on of your classes (if you want to me more OOP purist) – would be perfectly fine for this, yes.

Many Thanks, i will try it that way.!

1 Like