I want to iterate through and array passed to a subroutine but I need to know how many elements are in the array.
I want to iterate through and array passed to a subroutine but I need to know how many elements are in the array.
Use the INMAT() function, which, in UniVerse, returns a dynamic array.
subroutine foo(mat bar)
dim bar(1)
n = int(inmat(bar)<1, 1>)
Henry
I want to iterate through and array passed to a subroutine but I need to know how many elements are in the array.
Joe,
You could use DCOUNT to do this, DCOUNT(ARRAY,@AM) for example will count the number of attributes in the array. DCOUNT(ARRAY<2>,@VM) would count the number of mulitvalues in attribute 2.
If you just want to parse the array you could use REMOVE to do this as you do not need to know the number of elements in an array to use REMOVE to process the whole array.
Thanks,
I want to iterate through and array passed to a subroutine but I need to know how many elements are in the array.
Thanks Henry, that's what I needed. I had seen the INMAT function but the documentation made it seem like it was for determining how many elements a MATREAD had processed or to determine if the DIM statement succeeded. Further down it mentions that use can use it to get the size of a dimensioned array. I just didn't read down that far.
Jonathan,
I appreciate the response. I was trying to figure out a function that would work with dimensioned arrays. They're a different animal from dynamic arrays which are basically a delimited string.
Thanks guys!
Sign up
Already have an account? Login
Welcome to the Rocket Forum!
Please log in or register:
Employee Login | Registration Member Login | RegistrationEnter your E-mail address. We'll send you an e-mail with instructions to reset your password.