I am trying to make a procedure that will take an array and return a count of the used elements (why is this not a BIF??). I am struggling to find a way to pass an array of unknown size to my procedure.
Something like...
P count B
D count PI 3 0
D array *
D size 10 0
D elems 3 0
*
D ct S 3 0
/free
// find the first blank or zero element and return
/end-free
P count E
Obviously I am new to this, so I have a couple of questions:
- Is there any way around passing the size and max elements as parameters (or maybe a way of passing a sort of header packet with details about the data)?
- Is there any way of determining what type the data is? (so I know whether to look for *ZEROS or *BLANKS)
- Am I missing some other, better approach to this problem?
I know I could keep a separate counter variable that gets incremented whenever I set an element in the array, but I would really like to find a better solution... thank you for reading.