LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Store value for later use

I have a LabView code in which the first time the user has to enter a set of values through a wizard ( a separtate VI ) and go ahead. What I want to do is have a separate button on the main VI which will take in the default values ( or previously entered values ) of the wizard and directly go ahead without even popping up the Wizard VI

 

Thanks

0 Kudos
Message 1 of 16
(4,478 Views)

You'll need to store these values somewhere.  I like to use the OpenG configuration file VIs for this.

 

M3K CAN ESS Main_BD.png

 

Make a cluster that defines the data in the configuration (ini) file, open it, read it, (convert the variant and) close it and Bob is your uncle.

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 2 of 16
(4,461 Views)

Hi Jim

 

The wire coming out of the Wizard VI is in cluster form ( pink wire ). How do I write it to file and later refer to that storage for further use. Also could you please keep it a bit simple as im a new to it. Thanks

 

Soham

0 Kudos
Message 3 of 16
(4,439 Views)

The very simple way would to use the Write To Binary File and Read From Binary File.  These two functions will accept your cluster.  If resultant file likely won't be readable using a text editor, in case that is a requirement.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 4 of 16
(4,426 Views)

@Soham wrote:

Hi Jim

 

The wire coming out of the Wizard VI is in cluster form ( pink wire ). How do I write it to file and later refer to that storage for further use. Also could you please keep it a bit simple as im a new to it. Thanks

 

Soham


Do steps 1, 2, 3 and 6 to create the file.  Do steps 2, 4, 5 and 6 to read from it later.

 

Example_VI_BD.png

 

I can never remember how to format the configuration file, anyway, so I make a VI do steps 1, 2, 3 and 6 when I begin a project.  I always make a Type-Defined cluster, too.

 

Contents of created ini file:

 

Spoiler

[Sample Ini Data]
String Data = "Hello, World!"
Boolean Data = "FALSE"
Integer Data = "25"
Float Data = "2.710000"
Arrao-O-Stuff.<size(s)> = "1"
Arrao-O-Stuff 0.More Boolean Data = "TRUE"
Arrao-O-Stuff 0.More Integer Data = "10"
Arrao-O-Stuff 0.More Float Data = "3.140000"

 

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

Message 5 of 16
(4,417 Views)

@crossrulz wrote:

[...] resultant file likely won't be readable using a text editor, in case that is a requirement.


This is a good point; you may have a requirement that the file not be human-readable/editable.  I want my stuff to be readable in a text editor and I just use OS permissions (and threats of retribution) to prevent unauthorized access.

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 6 of 16
(4,408 Views)

Thanks Jim

 

Though can you explain how do I make a config file? Im really new to labview. Also could you tell me what this means (the picture attached)? 

0 Kudos
Message 7 of 16
(4,396 Views)

Look under the File palette -> Configuration file subpalette.

If you want to make it (decently) human readable with little work you'll read and write the config-cluster with as XML instead. 🙂

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 8 of 16
(4,376 Views)

@Soham wrote:

Thanks Jim

 

Though can you explain how do I make a config file? Im really new to labview. Also could you tell me what this means (the picture attached)? 


My last post tells you how to make the config file.  The picture you attached is of an enum or a ring constant.

 

 

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 9 of 16
(4,365 Views)

@Yamaeda wrote:

[...]

If you want to make it (decently) human readable [...]


Example_VI_BD.png

 

Right!

 

Spoiler
<Cluster>
<Name>Sample Ini Data</Name>
<NumElts>5</NumElts>
<String>
<Name>String Data</Name>
<Val>Hello, World!</Val>
</String>
<Boolean>
<Name>Boolean Data</Name>
<Val>0</Val>
</Boolean>
<I32>
<Name>Integer Data</Name>
<Val>25</Val>
</I32>
<DBL>
<Name>Float Data</Name>
<Val>2.71000000000000</Val>
</DBL>
<Array>
<Name>Arrao-O-Stuff</Name>
<Dimsize>1</Dimsize>
<Cluster>
<Name></Name>
<NumElts>3</NumElts>
<Boolean>
<Name>More Boolean Data</Name>
<Val>1</Val>
</Boolean>
<I32>
<Name>More Integer Data</Name>
<Val>10</Val>
</I32>
<DBL>
<Name>More Float Data</Name>
<Val>3.14000000000000</Val>
</DBL>
</Cluster>
</Array>
</Cluster>
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

Message 10 of 16
(4,364 Views)