04-29-2010 02:15 PM
Here is a very simple and crude WORM Global. It allows a write on the first call only. After that, any input data is ignored and the stored value is returned.
It has many drawbacks. It can only hold one variable. It uses variants in and out so that it can handle different data types. But hey, its a start. It would be nice if it could be made to handle multiple data objects (I hear the word OOP) and if it would not use variants.
Another drawback is if one attempts to write to it a second time, and is under the impression that the new value has been stored. He would be in for a rude awakening when he finds out that the original value is still there. It would be nice if the vi icon itself would change to reflect the data type and value of the initial setting.
Maybe I can work on a WORM-G creator vi, one that would create a new WORM vi on the fly. You would give it a name and some data. It would create a WORM vi with the name you gave it, and would use the data type of the input instead of a variant. Not sure how to change the icon programatically. Does scripting allow this?
False case has a wire straight through.
04-29-2010 04:29 PM
I like what you guys propose, but I would like to see something different.
In my mind, WORM Globals would be created like a TypeDef control where all the values are Constants, thus you can only read them at run-time.
You would want something that looks and feels like the current globals, without the ability to write to them at run-time.
If I have the time, I'll prepare an example.
04-29-2010 05:01 PM
Ray.R wrote:
In my mind, WORM Globals would be created like a TypeDef control where all the values are Constants, thus you can only read them at run-time.
You would want something that looks and feels like the current globals, without the ability to write to them at run-time.
Mon cousin du nord:
You are describing a Constant, not a WORM Global. A WORM (Write Once Read Many) Global is one in which it is written to one time only. For instance, at the beginning of a program, you might want to read an ini file (or some config file), and store some values in a global. Then these globals could not be written to ever again while the vi is running. Hence the term, write once read many.
There is a need for a constant also, one in which you set it up during development and it could only be read during runtime. I would like to have both.
I agree that both should have the look and feel of a current Global variable. Drop down a small icon on the block diagram and read its value. Or in the case of a true WORM-G, write to it once, then read only. It would be nice to have one Global VI that would hold many globals of different types, just like the current Global VI.
04-29-2010 05:14 PM
I'm going nuts these days.
You are correct, mon cousin du sud..
Okay.. now I really like your ActionEngine. Makes sense.
Sorry about the confusion..
04-30-2010 08:28 AM
Unfortunately, the people that would most benefit from this discussion don't hang here. I don't think any of us are abusing globals anyway.
04-30-2010 08:54 AM
tbob wrote:
Ben wrote:I thought about this this week-end.
WORM globals - (Write Once Read Many) globals are a safe use of globals provided you and only you are the developer and you remember that you used globals and already used-up your allotment of write globals.
Ben
A very practical thought, Ben. I would never use Globals in any way other than as constants or worm globals. The trick is to get others, those who might inherit your code, to do the same.
Has anyone coined the term Worm Globals yet? Or did I just invent something new?
Reminds me to the WOM
Have a nice weekend
04-30-2010 09:26 AM
Using scripting, you would first make your WORM design a template.
Create a new vi from that template.
Then replace the data control of theWORM with the global control. This will be a bit 'nasty' because I think the RepNoAttrib is one of the private/scripting methods that did change between diffrent versions of LV.
You then can programatically Replace all References of the global with the WORM in the code and delete the global...
As this weekend seems to become rainy, I propably code it...
Creating an Icon should be possible. Isn't the Icon editor written in G?
Felix
04-30-2010 09:37 AM - edited 04-30-2010 09:38 AM
oops
05-02-2010 06:17 PM
Update: rainy weekend over. Didn't code for this thread. Won't find the time before winter.
Felix
05-06-2010 08:31 AM
In this message I saw some say this that I think should be quoted and remembered.
"I tried to solve that with a local variable, but does not work correctly"