NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

How to converting string to array

Solved!
Go to solution

Hi all

  I have a demo,when input string "test123" need to assign array as uutdata[0]="t",uutdata[1]="e",uutdata[2]="s",uutdata[3]="t",uutdata[4]="1",uutdata[5]="2",uutdata[6]="3",why is only assign in element[0],thanks!!

 

why only assign in element[0]why only assign in element[0]

Download All
0 Kudos
Message 1 of 4
(3,359 Views)

1- You need to get the length of your string in 'SerialNumber'

2- Resize your array 'UUTdata'

3- Fill in 'SerialNumber' into 'UUTdata'

0 Kudos
Message 2 of 4
(3,333 Views)

Hi hbs

   Thanks for your reply,I have got input serial number length and resize the array,only don't know allocated the string in array elements, the procedure as below:

 

1)FileGlobals.Number_of_length = Len( FileGlobals.SerialNumber)

2)SetNumElements(FileGlobals.UUTdata, Len(FileGlobals.SerialNumber))

3)FileGlobals.UUTdata =  Split ( FileGlobals.SerialNumber,",")

 

I think is wrong with procedure(3),how to fix it,thanks!!

 

 

 

0 Kudos
Message 3 of 4
(3,329 Views)
Solution
Accepted by topic author Sam.Huang

use Mid

 

 

String Mid(String string, Number startIndex, [Number numberOfCharacters])

Example: of course, you can put it in For loop
Parameters.Arr[0] = Mid(Parameters.Serial, 0, 1),
Parameters.Arr[1] = Mid(Parameters.Serial, 1, 1),
Parameters.Arr[2] = Mid(Parameters.Serial, 2, 1),
Parameters.Arr[3] = Mid(Parameters.Serial, 3, 1),
Parameters.Arr[4] = Mid(Parameters.Serial, 4, 1)

 

 

hbs_80_0-1606382929075.png

 

0 Kudos
Message 4 of 4
(3,323 Views)