NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Is it Possible to Use Numeric Variables in a String Variable for Filenames?

Solved!
Go to solution

Hi All,

I really don't know how to phrase this question correctly, but here is my question.

 

I have a DotNet object and a method someone else wrote to write to an Excel file. I want to use something like: "C:\Program Files\WMT\Sequences\ProductX "+ Str(StationGlobals.File_Count) +".arc" in a local or global string variable, but I always get a illegal characters in filename. If I put that into the string filename parameter  in value -- it works. The variable File_Count is a number.

 

TIA,

Jim

0 Kudos
Message 1 of 9
(3,432 Views)

In a string constant in an expression, the backslash character is the escape character. To put a real backslash, you double it:

 

"C:\\Program Files\\WMT\\Sequences\\ProductX "+ Str(StationGlobals.File_Count) +".arc"

 

 

From the Expression Browser Help for string constants:

You can use the following escape sequences in string constants:
 \\ Backslash
 \n Line Feed
 \r Carriage Return
 \xNN Hexadecimal character code
 \NN LabVIEW style hexadecimal character code
 \" Quote
 \t Tab

 

Message Edited by James Grey on 04-17-2009 09:28 AM
0 Kudos
Message 2 of 9
(3,429 Views)

Hello James,

 

Actually i am very new to TestStand. So maybe I may not understand the Thread Problem properly.

I just framed one Seq from whatever i understood..i tried using single backlash..but my string was formed properly..why so?

 

0 Kudos
Message 3 of 9
(3,425 Views)
The characters that follow the backslashes in the example just happen not to form valid escape sequences. I didn't see documentation for what happens in that case, but it looks like invalid escape sequences are just left alone.. In your example, try renaming the WMT folder to TWMT and the leading T will become a tab character. I'm not sure if Jim was seeing the problem with a different string (maybe 'ProductX' was not what he was seeing the problem with) or maybe I misunderstood and his string was not being evaluated in TestStand.
Message Edited by James Grey on 04-17-2009 10:04 AM
0 Kudos
Message 4 of 9
(3,421 Views)

Yes i checked it James..you are right!!

 

Thanks for the reply

0 Kudos
Message 5 of 9
(3,417 Views)

Hi James,

Thanks for the help, but my problem seems to be from including variables in a variable (and a conversion to string). I hope the following example will show the problems I am having.

Thanks,

Jim

0 Kudos
Message 6 of 9
(3,407 Views)

Only use escape characters in string constants in expressions.

 

Don't put them in your local string variables when you edit their values, even if you use the locals as variables in an expression.

0 Kudos
Message 7 of 9
(3,405 Views)

Hi James,

How do I put a reference a local variable in a local variable? I want to do something like this for the filename variable in my previous example:

 

"Serial Number  " + Str(StationGlobals.File_Count) + " .txt"

 

Thanks,

Jim

0 Kudos
Message 8 of 9
(3,394 Views)
Solution
Accepted by topic author Jim_Flip

Put the reference in your expression itself, or compute the value of the second local using an another expression that references the first local.

 

The expression in your first post would work fine when used as an expression if the backslashes were escaped (doubled).

Message Edited by James Grey on 04-17-2009 12:40 PM
0 Kudos
Message 9 of 9
(3,392 Views)