I have string in PowerBuilder:
string test_string = "1,2,3,4,5"
I want to convert it to array:
string array[] = {'1','2','3','4','5'}
How to do that?
// Thanks for help :)
I do that:
string string_to_edit = "1,2,3,4"
string array[], string_now
long arraylen, stringlen, place_nbr, i, place_tt
stringlen = len(string_to_edit)
DO WHILE stringlen > 0
place_nbr = pos(string_to_edit, ",")
IF place_nbr > 0 THEN
place_tt = place_nbr - 1
string_now = Mid(string_to_edit,0,place_tt)
string_to_edit = RIGHT(string_to_edit,stringlen - place_nbr)
stringlen = stringlen - place_nbr
ELSE
string_now = string_to_edit
string_to_edit = RIGHT(string_to_edit,stringlen - place_nbr)
stringlen = 0
END IF
string_now = trim(string_now)
arraylen = UpperBound(array)
array[arraylen+1] = string_now
LOOP
You can get inspiration by looking at the way that it's done in the PFC ( the of_parsetoarray() function) :
https://pfc.svn.codeplex.com/svn/12.0/pfcapsrv/pfc_n_cst_string.sru