- Dan Cooperstock
- PowerBuilder
- Friday, 19 January 2024 04:42 PM UTC
I need to test whether the value in a variable of type "any" is an array or not.
What I have found out is that UpperBound(vbl) returns -1 if it's not an array.
That's at least arguably consistent with the documentation, which says (of the 2nd argument n, the dimension you want the upperbound of) "If n is greater than the number of dimensions of the array, UpperBound returns -1."
So since if you don't provide that 2nd argument, it defaults to 1, and thus it makes sense that if the number of dimensions of the variable is less than 1, i.e. it's not an array, the function returns -1.
Does that seem like a reliable test? I have some code that crashes if I accidentally pass in an array (but can be modified to handle it if I know it's an array!) so I need this test.
BTW I have also observed that ClassName(vbl), when vbl refers to an array, often crashes PB. (That's in PB 2021 Build 1509.)
Thanks.
Find Questions by Tag
Helpful?
If a reply or comment is helpful for you, please don’t hesitate to click the Helpful button. This action is further confirmation of their invaluable contribution to the Appeon Community.