Read numers and save to file

I need Help with this :
Loc:numbers = “1,2,3,4,5” etc. ( string with numbers and ,) and I want to loop throu that string and save each number into file bro:number = 1
Bro:number = 2… thank’s!

Something like this:
PROGRAM

  MAP
  END

instr                         STRING('1,2,3,4,5')
curchr                        STRING(1)
numstr                        STRING(10)
I                             LONG, AUTO

  CODE
  LOOP i = 1 TO LEN(CLIP(instr))
    curchr = instr[i]
    CASE curchr 
    OF ','
      MESSAGE('Found number '& CLIP(numstr))
      numstr = ''
    OF '0' TO '9'
      numstr = CLIP(numstr) & curchr
    ELSE
      !- invalid char
    END
  END
  
  !- last number
  MESSAGE('Found number '& CLIP(numstr))

Thank you , Mike!!! Saved my day!