viewpoint-particle

Author Topic: Is there a function to test if an array is empty?  (Read 174 times)

SewWrite

  • Newbie
  • *
  • Posts: 4
Is there a function to test if an array is empty?
« on: May 03, 2020, 11:46:08 am »
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

  • Tech Support
  • *****
  • Posts: 3453
    • WinBatch
Re: Is there a function to test if an array is empty?
« Reply #1 on: May 03, 2020, 12:56:27 pm »
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
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

  • Newbie
  • *
  • Posts: 4
Re: Is there a function to test if an array is empty?
« Reply #2 on: May 03, 2020, 04:52:33 pm »
Thanks... that worked. Duh! Simple once you know the answer. Now onto the next bug. :)