BreakPoint

cancel
Showing results for 
Search instead for 
Did you mean: 

Are globals really THAT evil?

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.

 

 

- tbob

Inventor of the WORM Global
0 Kudos
Message 71 of 89
(10,999 Views)

tbob wrote:

[...]

I'm open to suggestions on how to make it better.

 


Good job, I like it. Smiley Happy

 

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.

The work-around is to Delete 'em before you make 'em, but Delete All would still help in this case.
Message Edited by Broken Arrow on 05-11-2010 03:20 PM
Richard






0 Kudos
Message 72 of 89
(10,989 Views)

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.

 

- tbob

Inventor of the WORM Global
0 Kudos
Message 73 of 89
(10,973 Views)

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.

 

 

- tbob

Inventor of the WORM Global
Message 74 of 89
(10,963 Views)
Just a few minor points, the WORM passes an error "Name already exists: " if an empty string is passed in and the Error In doesn't do anything.  I guess it wouldn't matter if you're reading, but I don't know if it should it allow an Add if an up-stream operation resulted in an error.
Message Edited by jcarmody on 05-12-2010 07:38 AM
Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

0 Kudos
Message 75 of 89
(10,936 Views)

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.

 

- tbob

Inventor of the WORM Global
Message 76 of 89
(10,930 Views)

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.

 

Toss_LV.gif

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 77 of 89
(9,990 Views)

@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.

 

Toss_LV.gif

 

Ben


It does have a block diagram Ben and it will execute


"Should be" isn't "Is" -Jay
0 Kudos
Message 78 of 89
(9,954 Views)

@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.

 

Toss_LV.gif

 

Ben


It does have a block diagram Ben and it will execute


I will let you explain that.

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 79 of 89
(9,926 Views)

@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.

 

Toss_LV.gif

 

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)


"Should be" isn't "Is" -Jay
Message 80 of 89
(9,922 Views)