Hi
I have a 1 dimensional array of strings. The size can be dim(xxx). I would like to create a procedure that takes my array as a parameter to subsequently remove all empty strings and move the strings together, and return it - preferably as a pointer.
Can this be done in Clarion?
/Niels
se a LOOP. I’m on my phone so this may not be perfect
StringArrayCompress PROCEDURE(*STRING[ ] Str),LONG,PROC
N LONG
T LONG ! Out index
Code
LOOP N=1 TO MAXIMUM(Str[],1)
!Wrong: IF Str[N] THEN CYCLE. Leaves only blanks :(
IF Str[N] = '' THEN CYCLE.
T += 1
IF T = N THEN CYCLE.
Str[T] = Str[N]
Str[N] = ''
END
RETURN T
! Return how many found, PROC makes optional
Example
Addr STRING(50),DIM(5)
...
Addr[1]=Vendor:Address1
... [2]=2 ... 3 ... 4
Addr[5]=Clip(City) & Clip(' '&State) & Clip(' '&Zip)
IF StringArrayCompress(Addr[]) >= 5 THEN
! Print 5 line address smaller
ELSE
! Print bigger if 4 or less lines
1 Like
Well, as done on a phone it’s pretty impressive. But at first glance it makes good sense. I try.
THANKS
Agree. Good work Carl.
I am also on my phone waiting in my car but I think the line at the top of the loop with the cycle should have a not on the condition.
IF not Str[N] THEN CYCLE.
Or alternatively
IF Str[N] = '' THEN CYCLE.
Cheers
Geoff R
1 Like
Dang, I had it IF ~
then “tried” to change to IF ... =' '
but forgot some
2 Likes