0

I'm a beginner at coding in Clarion and I'm coping with problem which can be described as basic.

I have this code: L_COUNTER1 = 2 LOOP IF INSTRING(L_COUNTER2& ';',L_STRING,1,L_COUNTER1 = 0 THEN
L_LIST[L_COUNTER2] = SUB(L_STRING,2,L_COUNTER1-3) L_STRING = SUB(L_STRING,L_COUNTER1,LEN(L_STRING) - L_COUNTER1 + 1) BREAK ELSE L_COUNTER1 = L_COUNTER + 1 END

Variable Counter1 is part of the outer loop. This code produces me data such

L_LIST[1]='test1'
L_LIST[2]='test2'
L_LIST[3]=''(empty)
L_LIST[4]=''(empty)
L_LIST[5]=''(empty)
L_LIST[6]='test3'
L_LIST[7]=''(empty)
L_LIST[8]=''(empty)
L_LIST[9]=''(empty)

I'm trying to achieve:

L_LIST[1]='test1'
L_LIST[2]='test2'
L_LIST[3]='test3'

Or at least

L_LIST[1]='test1'
L_LIST[2]='test2'
L_LIST[3]='test3'
L_LIST[4]=''(empty)
L_LIST[5]=''(empty)
L_LIST[6]=''(empty)
L_LIST[7]=''(empty)
L_LIST[8]=''(empty)
L_LIST[9]=''(empty)

But I'm stuck on this problem. I tried looping through the elements and checking if they're not equal to empty string but didn't have much success.

  • Guessing that you meant: `IF INSTRING(L_COUNTER2& ';',L_STRING,1,L_COUNTER1) = 0 THEN` instead of `IF INSTRING(L_COUNTER2& ';',L_STRING,1,L_COUNTER1 = 0 THEN` – riffrazor Dec 14 '19 at 16:58

1 Answers1

0

Testing the contents should be something like IF CLIP(L_STRING) > '' (checks for content in the string) or IF CLIP(L_STRING) = '' (check for empty string)

The rest of the solution is to code up a sort for the dimensioned string variable L_LIST. Or use a queue and use SORT(queue,listfieldname)

Unless I dont understand the question (or I'm missing some context), there really isnt any need to step through the string a character at a time.

riffrazor
  • 447
  • 5
  • 8