NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

String = String + Number

I'm using TestStand to piece together some diagnostic messages we use to communicate with our products in the factory.  My message has 10 bytes (02 44 07 31 40 04 00 10 00 01).  Its declared as a string and sent to the instrument as such.  My problem is the assembly of this message.  The first part is in a variable declared as a Var1string = 02 44 07 31 40 04, but the ending, consisting of the last 4 bytes VarNum2 = 0x 00 10 00 01 is numeric/number.  When I piece it together I get   VariableString = Var1string + VarNum2, that is 02 44 07 31 40 04 + 0x 00 10 00 01, but I'm trying to get 02 44 07 31 40 04 00 10 00 01.  I can't remove the 0x, but I want to keep 00 10 00 01.  Does this make sense? 
 
Tony
0 Kudos
Message 1 of 5
(4,962 Views)

I'm not sure how you are actually concatenating the string and the number because using the + operator on a string and a number gives a type error. I'm also not sure how you are getting the spaces between bytes in your converted numeric value.

However, here are some things that might be useful:

1) SearchAndReplace("02 44 07 31 40 04  0x 00 10 00 01", "0x ", "")     gives  02 44 07 31 40 04  00 10 00 01

2) Str(0x00100001, "%x") gives 100001.  Note that there are no spaces between bytes. Spaces could be added by extracting the bytes with Mid() and glueing them back with spaces in between, but it seems like you already have a solution for that.

 

0 Kudos
Message 2 of 5
(4,960 Views)

For (2), I should have put the following to give the leading zeros:

Str(0x00100001, "%.8x")   gives   00100001

0 Kudos
Message 3 of 5
(4,948 Views)
Are you trying to get a string with embedded nulls in it into teststand (characters with a value of zero)? If so you might be better off using an array of numbers rather than a string. You can still pass it into code modules as an array of char data type so it should still work.

Hope this helps,
-Doug
0 Kudos
Message 4 of 5
(4,921 Views)
Another alternative if you are using TestStand 3.0 or higher and LabVIEW is that you can use escaped null characters in strings. When specifing the parameters for your VI call in TestStand, set the data type of your string parameters to Binary String. Then you can pass a string like, hello\00world, into the VI and TestStand will know to replace the \00 characters with an embedded null character when calling the VI.

-Doug

0 Kudos
Message 5 of 5
(4,919 Views)