IMPORTANT ANNOUNCEMENT

These forums were permanently set to read-only mode on July 20, 2022. From that day onwards, no new posting or comment is allowed on the site, but the historical content remains intact and searchable.

A new location for posting questions about PlanetPress Suite is now available:

OL Learn - PlanetPress Classic (opens in new tab)

Topic Options
#57228 - 09/24/19 12:04 PM how to separate strings between delimiters
bbauser Offline
OL Newbie

Registered: 09/24/19
Posts: 11
I have the following string
'|a:100 b:200 c:300|a:200 b:200 c:300'

I want to assign them to variables like so
&string1:= 'a:100 b:200 c:300'
&string2:= 'a:200 b:300 c:400'

how would I do that without having to do it manually like I did above?

I was thinking of using search() or pos(), but I noticed pos() only looks for the first instance and I'm not exactly sure how to do it with search(). Could someone please assist?

Top
#57231 - 09/26/19 10:42 AM Re: how to separate strings between delimiters [Re: bbauser]
Philippe F. Offline
OL Expert

Registered: 09/06/00
Posts: 1984
Loc: Objectif Lune, Montreal, Qc
Use something like this:
Code:
define(&line,string,@(1,1,50))


define(&values,arraystring,['','','','','','','',''])
define(&counter,integer,0)
search(&line,'|')
   if(&line<>'')
        &values[&counter]:=&line
        &counter:=&counter+1
   endif()
endsearch()
&values[&counter]:=&line
define(&i,integer,0)
for(&i,0,1,&counter)
        show(&values[&i])
        crlf()
endfor()
_________________________
Technical Product Manager
I don't want to achieve immortality through my work; I want to achieve immortality through not dying - Woody Allen

Top