LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Is it possible to obtain a list (string) of all elements within a Global Variable?

A search got me this:  http://forums.ni.com/ni/board/message?board.id=170&message.id=159492

Which is NOT good news.... 😞

The problem is that I do not know what "types" to expect.  I didn't mention that the Globals contain floats, integers and arrays of numeric.

Yikes...  Maybe time to consider an alternative approach??  Humm...

😮 😞 😮

0 Kudos
Message 21 of 47
(2,437 Views)

Hi Ray,

You are seriously abusing this thread " Is it possible to obtain a list (string) of all elements within a Global Variable? " Smiley Wink

I can NOT send or post my "Save_Restore_All_Controls.VI" where I have done both reading and writing from an abritrary target VI since it one of the product we sell.

I can tell you about some of the stuff I have read in JPD postings and some other random thoughts.

When I mentioned that you could just go with the variant, it was in the context of writting to the control. This part is easy because LV does all of the work of converting what you are presenting to the "Value" into the data type of the traget object.

Reading becomes an issue because LV needs to know about the wire type that it should add to the BD to carry that data.

To get around that complication you will have to work up some code that will take a generic reference and return a single data type.

Last part first!

So lets say what ever data type you have your code will return an array of floats. If the object is just an interger or a float, the function will retun that as an array of floats with a single element.

Now to your current query...

Pass the generic reference into a while loop with a case for each supported data type.

Try converting to each of your data types using the "To more Specific".

An error indicates wrong data type keep trying.

See below,

I hope this helps,

Ben

Message Edited by Ben on 09-29-2006 09:02 AM

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 22 of 47
(2,429 Views)

Thanks Ben,

I had just found a workaround..  My mistake..  I was feeding the wrong type when it encountered the array.  Even if it was an array of floats..

After additional cafeine, got it to work.  However, I much prefer your approach which adapts to the different types..  Interesting.   🙂

I'm starting to like working with variants!  🙂

More stuff to LuV about LV!

RayR

Message 24 of 47
(2,419 Views)

How do you write to the Globals file using this method?

Scenario:  I have implemented this method to read and write control values to a Global file.  The reading part functions well.  The problem is when writing to the Global file.

Case 1:  Writing with Global.vi open.

When writing to the Global.vi file while it is open, the written values appear as expected.  The Global file is closed.  When re-opening the Global.vi file, the recently written values are replaced by the original ones, as if they were not saved.  Note that the Global file was not "saved" manually prior to closing.

Case 2:  Writing with Global.vi closed.

When writing to the Global.vi file while it is closed, the recently written values do not appear after opening the file.

I suspect that the values may be written to the Global.vi file but are not saved.  How do you save values to a Global file when using references to write the values?

0 Kudos
Message 25 of 47
(2,399 Views)

I think you are looking for two of the invoke nodes.

Make Current Values Default

Save Instrument

See image

I hope this helps,

Ben

Message Edited by Ben on 10-03-2006 08:34 AM

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 26 of 47
(2,402 Views)
Thank you
0 Kudos
Message 27 of 47
(2,393 Views)

Ben,

I have another one for you.  And yes, I've seen the posts where it mentions that what I'm about to ask cannot be done..   🙂

Everything can be done, right?

 

Here goes:

In the same context as our earlier discussion.  I have a Global variable with a Tab Control on it.  I have a main vi that looks at the pages of the Global Variable's Tab.  If it does NOT find a page with the appropriate title (name, label), I want to ADD a new page on the Tab Control of the global variable.  How do you implement this? 

I know you enjoy a challenge 😄

RayR

Message 28 of 47
(2,336 Views)


@JoeLabView wrote:

I have a Global variable with a Tab Control on it.  I have a main vi that looks at the pages of the Global Variable's Tab.  If it does NOT find a page with the appropriate title (name, label), I want to ADD a new page on the Tab Control of the global variable.  How do you implement this? 


There is a scripting method which allows adding pages to tabs, BUT it requires that the VI will be idle. If you're calling globals from that VI, then it will be loaded and you can't do it.

Basically, you'll need to run the VI which will do this creating when the global VI is not reserved for running. This can be done either before you run the VI (makes sense anyway, since there's no point in dynamically creating globals if you don't call them) or by having the VI as the top level VI and having it dynamically call the VI which will actually be using the globals.


___________________
Try to take over the world!
Message 29 of 47
(2,329 Views)

HI Joe,

I have to agree with tst that it can be done but how would you develop your app to use globals that do not exist?

DSC on the other hand already provides functionality like this.

I could dig up one of my VI's that creates clusters from a script and modify it for what you want but I'd first like to know how you are going to use globals that do not exist.

Curious,

Ben

 

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 30 of 47
(2,320 Views)