LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Variables created dynamically

Hi,

 

Can someone give me a hint about how to dynamically create variable in LV?

I'd like to have a VI which will load whole *.ini file and respectively create global variables with initialisation:

 

*.ini                               LV Variables

[Variables]                    

Var1=5               --->    Var1 = 5

Var2="werwer"   --->    Var2 = "werwer"

Var3="false"       --->    Var3 = "false"

 

Many thanks in advance.

 

0 Kudos
Message 1 of 5
(2,737 Views)

If you know ahead of time the structure of the Cluster then This Nugget on Control references may help. This image is a preview.

 

 

 

If you do not know the cluster structure you will have to use scriting to create the cluster.

 

Ben

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

Hi MimiKLM

 

I hope you're having a good day. Take a look at this link to the Developer Zone, I think it may be helpful for you:

http://sine.ni.com/devzone/cda/epd/p/id/993

 

There is also another forum thread that discusses creating shared variables programmatically:

http://forums.ni.com/ni/board/message?board.id=170&message.id=200742&requireLogin=False

 

I hope this helps!

 

Kind Regards

Jeremy T
Technical Marketing
NI
0 Kudos
Message 3 of 5
(2,689 Views)

I don't think creating shared variables on the fly is very appropriate if you just want to store configuration settings stored in an ini file.

 

I would consider searching the forums for the term functional global, which is a VI that stores user-configurable data that can be accessed globally in your application. Your functional global could be designed to read and parse the ini file settings, and then allow access to arbitrary settings based on their key name.

Jarrod S.
National Instruments
Message 4 of 5
(2,677 Views)

Jarrod S. wrote:

...

 

I would consider searching the forums for the term functional global, ...


I'm on the same page... so much so that included in the example code in the Nugget I sited above, you will find an Action Engine (Functional Global) included. Theoretically all you have to do to my example is replace my type-def with your cluster and you are good to go (provided you did not use a data type that I did not code up).

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 5 of 5
(2,672 Views)