05-11-2010 02:29 PM
Here is my first attempt at a WORM Global. It is written in LV2009. That's all I got, so sorry for those of you who have earlier versions. Perhaps someone could convert it to 8.6, 8.5, or 8.2.
Anyway, I am using an array of clusters, where each cluster contains a string (Global name) and a Variant (data value). I use an Action Engine architecture to hold the list of globals (array) in a shift register. The actions are Add, Read, and Delete. Notice that there is no Write. When you add, you specify the value then and then only (Write Once). You can read as many times as you like (Read Many). The code checks to see if a name exists before adding it again. It also checks to see if the name exists before reading or deleting. Appropriate error messages are sent to Error Out in case of duplicate names or name not found.
You call it like any other VI and send in the Action enum, Global Name, and if adding, the value. It returns a value when reading. So you would have to call this vi for every global you want to add. Not the best scenario, I know. I guess you could create an array of globals and an array of values, and use a loop to add them all. But once added, you cannot overwrite what is there. No race conditions, ever.
I'm open to suggestions on how to make it better.
05-11-2010 03:18 PM - edited 05-11-2010 03:20 PM
tbob wrote:[...]
I'm open to suggestions on how to make it better.
Good job, I like it.
Upon leaving a program, you need to delete all of the WORMS, else the next time you run your ap, the WORMS you create will throw an error that they already exist. To make this task easier, you could have this VI contain a Delete All. (I'm talking development mode here, an I'm assuming you would create a series of WORM globals in your initialization routine, just like Obtaining Queues or Notifiers). The caveat is, if you use Abort to quit (which we all do during development, admit it) you'll still throw the errors.
05-11-2010 04:11 PM
Great suggestion. Thanx, Broken Arrow. Here is the vi with the Delete All added on. It would be best to call the Delete All the first thing in your program, then add globals after. That way, even an abort would not mess things up.
05-11-2010 05:24 PM
I just had another idea. Instead of leaving it up to the user to Delete All, I incorporated it into the VI to be called on First Call only. So the user just has to start defining globals without having to worry about clearing the array. On first call, the array is cleared, then the first command takes place. On subsequent calls, just the command happens. No worries.
05-12-2010 06:31 AM - edited 05-12-2010 06:38 AM
05-12-2010 12:23 PM
Good catch Jim. I've fixed that problem. I started a new thread here to alert more people to the new WORM Global idea. The vi attached there has the fix.
07-30-2018 09:32 AM
I am trying to upgrade an application that was developed by some other person and I am getting smacked in the face by globals. Not because of the previous reasons but for a new reason that I want to add to the list.
At least twice today I was chasing down all of the references to a global when I was confounded why "ctrl-e" was not working. Of course ctrl-e does not work when looking a the global itself that does not have a block diagram.
Ben
07-31-2018 04:20 PM - edited 07-31-2018 04:22 PM
@Ben wrote:
I am trying to upgrade an application that was developed by some other person and I am getting smacked in the face by globals. Not because of the previous reasons but for a new reason that I want to add to the list.
At least twice today I was chasing down all of the references to a global when I was confounded why "ctrl-e" was not working. Of course ctrl-e does not work when looking a the global itself that does not have a block diagram.
Ben
It does have a block diagram Ben and it will execute
08-01-2018 11:13 AM
@JÞB wrote:
@Ben...At least twice today I was chasing down all of the references to a global when I was confounded why "ctrl-e" was not working. Of course ctrl-e does not work when looking a the global itself that does not have a block diagram.
Ben
It does have a block diagram Ben and it will execute
I will let you explain that.
Ben
08-01-2018 01:30 PM - edited 08-01-2018 01:42 PM
@Ben wrote:
@JÞB wrote:
@Ben...At least twice today I was chasing down all of the references to a global when I was confounded why "ctrl-e" was not working. Of course ctrl-e does not work when looking a the global itself that does not have a block diagram.
Ben
It does have a block diagram Ben and it will execute
I will let you explain that.
Ben
WARNING! DO NOT GO HERE! Create a static reference to Global.vi
Ctrl+double click
Rinse out your eyes and forget what you saw.
(unless you want to write the call- chain and time to a log. which, you might want to do... You may be able to export the image of the FP never tried, but I would never try to read a value since that might recurse)