Differences
This shows you the differences between two versions of the page.
— |
is_array_empty [2021/04/05 11:23] (current) |
||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== 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. | ||
+ | |||
+ | <sxh> | ||
+ | dcl-proc main; | ||
+ | |||
+ | dcl-s values char(10) dim(3); | ||
+ | dcl-s allValues char(30) based(ptr); | ||
+ | ptr = %addr(values); | ||
+ | |||
+ | values(2) = ' | ||
+ | |||
+ | if (allValues = *blank); | ||
+ | dsply ' | ||
+ | else; | ||
+ | dsply 'not blank'; | ||
+ | endif; | ||
+ | |||
+ | end-proc; | ||
+ | </ | ||
+ | |||
+ | {{tag> |