NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

How to check whether array with string is empty or not

hi,

 

I know how to check with array with variables but i am not sure how to check for array with strings......

 

Pls let me know.

 

thanks

0 Kudos
Message 1 of 14
(9,295 Views)

Are you looking to see if an array of strings is empty?  getnumelements(array name) == 0

 

Are you looking to see if an array of strings has an empty string in it?  Use a FOR loop to go through each element and perform a check with an empty string ("").


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
Message 2 of 14
(9,293 Views)

I have declared the array with string and I need to check whether this array has any strings present or not......

0 Kudos
Message 3 of 14
(9,287 Views)

I'm still not following you.

 

Ok, you have an array of strings.  Is the array declared as a certain size or start off empty?  Are you adding and removing elements from the array?  Can you show some code to demonstrate your setup?


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 14
(9,284 Views)

 

size of Array of string is declared as a empty under parameter......in future i may add strings to that array and i need to check whether array is empty or not before procedding with other conditions.......

 

 

Ex:

 

 

parameters.string Arr[]

 

if (parameters.string arr[] == empty)

    failed

else

    a= name 1 = name 2

 

So i need to check string arr[] is empty or not

 

if (parameters.string arr[] is not empty)

   b= name2 + name 3

else

    a= name 1 = name 2

 

 

pls let me know

 

thanks,

chethan

 

I'm still not following you.

 

Ok, you have an array of strings.  Is the array declared as a certain size or start off empty?  Are you adding and removing elements from the array?  Can you show some code to demonstrate your setup?

0 Kudos
Message 5 of 14
(9,279 Views)

Use the GetNumElements function:

locals.empty = (getnumelements(parameters.array) == 0)


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 6 of 14
(9,270 Views)

Mandya,

 

Crossrulz already gave you the solution in his first post.  You need to use the GetNumElements function in an expression.  This function takes an array as its parameter and returns the number of elements in the array.

 

So GetNumElements(Parameters.MyArray) == 0

 

From the TestStand help:

Number GetNumElements(Array array)
This function returns the number elements in an array.
Parameter 1: A single dimensional array.
Returns:     The number of array elements.

 

Cheers,

 

jigg
CTA, CLA
testeract.com
~Will work for kudos and/or BBQ~
0 Kudos
Message 7 of 14
(9,269 Views)

can i use same concept for contianer also

 

i mean getnumelements(parameters.container.arr1)...pls let me know

0 Kudos
Message 8 of 14
(9,209 Views)

@Mandya wrote:

can i use same concept for contianer also

 

i mean getnumelements(parameters.container.arr1)...pls let me know


It looks like you are still looking at an array.  It is just inside of a container.  Should have no problems.


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 9 of 14
(9,206 Views)

what is

GetNumSubProperties Method

0 Kudos
Message 10 of 14
(9,202 Views)