BCX Console Demonstration Program s84.bas |
DIM SHARED i, j, a$, Stak$[41] CLS a$ = "1,22,333,4444,55555,666666,7777777,88888888,999999999," i = Parse(a$, ",") FOR j = 1 TO i PRINT Stak$[j] NEXT j FUNCTION Parse(Lyne$, Delim$) LOCAL Element LOCAL A LOCAL Tmp LOCAL Lin$ FOR Tmp = 1 TO 40 Stak$[Tmp] = "" NEXT Tmp Lin$ = Lyne$ : A = 1 : Element = 1 WHILE A > 0 A = INSTR(Lin$, Delim$) IF A > 0 THEN Stak$[Element] = MID$(Lin$, 1, A - 1) Lin$ = MID$(Lin$, A + 1, LEN(Lyne$)) IF LEN(Stak$[Element]) = 0 THEN DECR Element INCR Element END IF WEND Stak$[Element] = Lin$ IF LEN(Stak$[Element]) = 0 THEN DECR Element FUNCTION = Element END FUNCTION
Result:
1 22 333 4444 55555 666666 7777777 88888888 999999999