Is there a function to test if an array is empty?

Started by SewWrite, May 03, 2020, 11:46:08 AM

Previous topic - Next topic

SewWrite

I'm stumbling over what I thought would be easy. I return selected items from a dialog with Report View. I need to be able to have nothing selected but I can't seem to find how to test for it so the rest of my code fails when it bumps into the empty array.(I won't bore you with the list of what I've tried. It's long.) Is there a function I'm missing? If not, how can I test for an empty array?

Thanks for you help!

td

It depends on what you mean by "empty".   If you mean by "empty" that an array has no rank (no dimensions) then the task is simple. 

Code (winbatch) Select
aEmpty = ArrDimension(0)
if ArrInfo(aEmpty, 1) then strEmpty = 'No'
else strEmpty = 'Yes'
Message('Is the Array "empty"?', strEmpty)


If you are referring to a dimensioned array with uninitialized elements, you would need to check each element with the IsDefined function.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

SewWrite

Thanks... that worked. Duh! Simple once you know the answer. Now onto the next bug. :)