User Tools

Site Tools


is_array_empty

Is Array Empty?

To test if a character array is empty you can iterate through all elements to check each element separately.

Another method is to sort the array and then look if the first element is empty (empty elements should come last if sorted).

You can also overlay the whole array with another variable and just check the variable if it is blank.

dcl-proc main;

  dcl-s values char(10) dim(3);
  dcl-s allValues char(30) based(ptr);
  ptr = %addr(values);

  values(2) = 'hallo';

  if (allValues = *blank);
    dsply 'blank';
  else;
    dsply 'not blank';
  endif;

end-proc;

is_array_empty.txt · Last modified: 2018/02/07 08:47 by mihael