At 16:23 -0400 06/15/2004, George Gatling (Contractor) wrote:
>From my days as a C programmer (shudder) I have to say I do miss the #define.  I 
>realize LabVIEW cannot really have an exactly analogous feature because the scope of 
>.vi is too different from the scope of .c, but there must be some way to get the same 
>functionality.  I figure a global might be the ticket here, but I thought I would 
>ping you guys and see if anyone had something more clever or if there were any 
>gotchas to using a global.  I would type my #define values into the global, make 
>current values default, and then read from the global.  This particular global would 
>never get written to programmatically.

You need to disconnect the global from the running hierarchy to "make current values 
default".  You might consider intelligent LV 2 style globals where the first time they 
are called, they load from a config file.  When a global is written to, the 
corresponding element of the config file is updated.

You can use the built in config file management or the tool kit recently offered for 
sale.  :-)

The LV style global can check for first run and load the initial values.  It can keep 
an array of keys and return variants for that key.  Then for each global make a VI 
that passes the correct character string key and casts the variant into the correct 
representation to return to the user.  Then each of these VIs can be used just like a 
"read global".

A bit more complicated, but very robust and makes it easier to update single values 
rather than making all values default after stopping and starting the VI.  Then 
forcing the changed VI (defaults changed) to be saved.

That being said, I have also made a global to hold constants that I hope never vary.  
It will work.

-Scott


Reply via email to