Empty array


#1

Hi all,

i need to check an array to determine if is empty or not, i thought “isEmpty” was appropriate , but seems to work only on string not on array, and my code return false even the arrTest value is empty.

How can i check that ?

Thx.

Call Main()
Sub Main()
	Dim arrTest()
	
	If isEmpty(arrTest) Then 
		rhino.Print True
	Else 
		rhino.Print False
	End If 
	
End Sub


(Dale Fugier) #2

Hi Cyril

VBScript’s IsEmpty method check to see if a variable is empty, or uninitialized. It doesn’t check whether or not an array contains elements.

If you want to verify a variable is an array, use the IsArray method.

To determine the bounds of an array, use UBound.

More good stuff:

http://developer.rhino3d.com/guides/rhinoscript/

Hope this helps.

– Dale


#3

Hi Dale,

Thanks for help,

I made some try with Ubound, Like below, but i got error message, i think i miss something.

Just for explanation, i Dim 2 arrays, then i fill one or other in some conditions, in some case , one array still empty , and i need to check that, how can i check the bound of an empty thing ?
Can you just show me how you write that ?

Call Main()
Sub Main()
	Dim arrTest()
	
	If Ubound(arrTest) < 0 then 
		rhino.Print True
	Else 
		rhino.Print False
	End If 
	
End Sub


(Dale Fugier) #4

Hi Cyril,

See the following knowledge base article:

http://developer.rhino3d.com/guides/rhinoscript/testing-for-empty-arrays/

– Dale


#5

Hi Dale,

Fantastic, i understood.

Thanks