NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Can I use the API 'Write' Method to write multiple variables to a single text file?

Solved!
Go to solution

Hi All,

 

I am new to TestStand, I have used the write method to write values in my local variable (Locals.Parameters) to a text file address specified in my local variable (Locals.FilePath):

Locals.Parameters.Write (Locals.FilePath, "MY_GLOBALS", 0)

 

I have set the RWoptions = 0 (indicating default behaviour). 

 

I now want to write more than one variable (Locals.Parameters and Locals.Parameters2) to my text file which Locals.FilePath points to. I tried setting RWoptions = OR (bitwise-OR as described in TestStand help:

Locals.Parameters.Write + Locals.Parameters2.Write (Locals.FilePath, "MY_GLOBALS", OR)

 

This doesn't work so I tried to individually write them but this only writes the last variable (Locals.Parameters2):

Locals.Parameters.Write (Locals.FilePath, "MY_GLOBALS", 0),

Locals.Parameters2.Write (Locals.FilePath, "MY_GLOBALS", 0)

 

Is it possible to write multiple variables to a text file and could you please enlighten me on how to implement this in TestStand code? (BTW I am using TS 2014)

Any help is much appreciated, thanks

 

 

0 Kudos
Message 1 of 4
(2,644 Views)

What I am trying to do here is use multiple text files with parameter settings defining different modes of parameter settings to run in my code. My code will have the following structure:

- Step1: Select text file.vi

- Expression1: Read Parameters from file & update variables

-Step2: Load parameters (parameters set from variables)

-Expression2: Write updates to parameters(if parameters updated) to text file

 

Expression1: Locals.ReadEx (Locals.FilePathLabview, "Locals",0)

and

Expression2: Locals.Write (Locals.FilePathLabview, "Locals",0)

is doing what I require but I am selecting all my local variables. I want to only read and write to a selected number of local variables only. 

0 Kudos
Message 2 of 4
(2,585 Views)

Hey Sean,

 

Would you be able to provide a file showing what you have done already?

 

 

0 Kudos
Message 3 of 4
(2,576 Views)
Solution
Accepted by seanymac

Thanks for your reply. I came up with a simple solution to my problem. I simply added another layer of hierarchy. In the types pane I created a custom data type to combine all the data that I wanted to read/write to my text file. Then this allowed me to use the API write method:

 

Locals.Custom_Data_Type_Name.ReadEx (pathString, objectName, RWoptions)

and

Locals.Custom_Data_Type_Name.Write (pathString, objectName, RWoptions)

0 Kudos
Message 4 of 4
(2,566 Views)