10-28-2008 04:14 PM
I chose to try/use a global variable to resolve a complex situation I was having. I followed the "Creating Global Variables" from LabVIEW help and everything seemed to work fine. The global stopped working, however, when I checked my files into CM and the xxxGlobal.vi (created by the global variable process) was readonly. I didn't see a runtime error, but the global always returned the default. Then, when I changed the file's attributes (enchecked readonly), I could exercise the other functionality.
Is this a known issue - do I have to make this global.vi read/write for all users, or is there another solution?
10-28-2008 04:27 PM
10-28-2008 04:30 PM
10-28-2008 05:32 PM
I don't think my conclusion (above) is correct. I had a case statement error that made it appear that the readonly was the issue, when it was not. I'm not sure what the deal is now. Here is what I did.
I placed a global variable(gv) in the block diagram of one VI, then double clicked on the gv and got a blank vi. I dropped a text control onto the front panel and named it ReportFormat. I then did a "save as" to save the new (global) VI. I then added some logic (where I originally dropped the gv) to populate the global variable with the user's selection from a drop down (two possible choices) . I then went to another VI and in its block diagram I did a "Select VI", found/selected this global.vi I just created. Since I only have one item on the front panel (in the global.vi), I received an association to ReportFormat. I did a "Change to Read" so I can use the string output to drive a case statement. The default case is always selected, though.
10-29-2008 01:44 PM
It sounds like you're using the global correctly, but my guess is that you simply didn't write a value into the global. You can do this manually or in the code. Of course, you also need to make sure that you don't overwrite the value. In general, globals can be dangerous, as they have a potential for creating race conditions (at least if you have more than one writer), but if your use case is simple, you can probably use it safely.
I assume the example finder (Help>>Find Examples) probably has some examples for using globals, so you can try searching it.