Advertisement
a3f

Parse a csv to an array

a3f
Mar 15th, 2012
1,241
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. REM We could use a goto command to make it similar to a function but a function itself isn't possible
  2. REM JustBasic doesn't accept arrays as return values
  3.     row$ = "3,5,6"
  4.     n = 3
  5.  
  6.    dim value$(n)
  7.  
  8.         for i = 0 to n-1
  9.             if instr(row$, ",") <> 0 then
  10.                 comma = instr(row$, ",")
  11.                 value$(i) = left$(row$, comma - 1)
  12.                 row$ = right$(row$, len(row$) - comma)
  13.             else
  14.                 value$(i) = row$
  15.             end if
  16.                 values(i) = VAL(value$(i))
  17.           next i
  18.  
  19.  
  20.     for m = 0 to n-1
  21.         print values(m)
  22.     next m
Advertisement
RAW Paste Data Copied
Advertisement