Focal Point
[SOLVED] Split the string based on delimiter

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/2607088986

April 09, 2018, 10:37 AM
SridharLakshmipathy
[SOLVED] Split the string based on delimiter
Hi ,

We have input data with delimited string ,
how to split the String based on the delimiter.

-SET &input_data= 'England;Germany;Japan;France';

Needed Output Format
England
Germay
Japan
France

Could you please let us know how to achieve it ?
Thanks

This message has been edited. Last edited by: FP Mod Chuck,


WebFOCUS 8

Windows, All Outputs
April 09, 2018, 10:42 AM
BabakNYC
Take a look at he character functions here, specifically GETTOK and SUBSTR and SPLIT.

https://webfocusinfocenter.inf...urce/character28.htm

This message has been edited. Last edited by: BabakNYC,


WebFOCUS 8206, Unix, Windows
April 09, 2018, 03:41 PM
jfr99
Here's a Dialogue Manager example ...

-*
-SET &IN_STR  = 'England;Germany;Japan;France';
-SET &IN_DLM  = ';';
-*
-TYPE ---------------------------------------------------------
-TYPE IN_STR --- &IN_STR
-TYPE IN_DLM --- &IN_DLM
-TYPE ---------------------------------------------------------
-SET &Z1_DLM = &IN_DLM;
-SET &Z1_STR = TRUNCATE(&IN_STR) | &Z1_DLM;
-SET &Z1_LEN = ARGLEN(&Z1_STR.LENGTH, &Z1_STR, 'I3');
-SET &OT_STR = '`';
-REPEAT :Z1_LOOP FOR &I FROM 1 TO &Z1_LEN;
-SET &Z1_CHA = SUBSTR(&Z1_LEN, &Z1_STR, &I, &I, 1, 'A1');
-IF &Z1_CHA EQ &Z1_DLM THEN GOTO :Z1_OUT;
-SET &OT_STR = IF &OT_STR EQ '`' THEN &Z1_CHA ELSE &OT_STR | &Z1_CHA;
-GOTO :Z1_LOOP
-:Z1_OUT
-TYPE OT_STR --- &OT_STR
-SET &OT_STR = '`';
-:Z1_LOOP
-TYPE ---------------------------------------------------------
-RUN



WebFocus 8.201M, Windows, App Studio
April 10, 2018, 02:05 AM
SridharLakshmipathy
quote:
Originally posted by jfr99:
Here's a Dialogue Manager example ...

-*
-SET &IN_STR  = 'England;Germany;Japan;France';
-SET &IN_DLM  = ';';
-*
-TYPE ---------------------------------------------------------
-TYPE IN_STR --- &IN_STR
-TYPE IN_DLM --- &IN_DLM
-TYPE ---------------------------------------------------------
-SET &Z1_DLM = &IN_DLM;
-SET &Z1_STR = TRUNCATE(&IN_STR) | &Z1_DLM;
-SET &Z1_LEN = ARGLEN(&Z1_STR.LENGTH, &Z1_STR, 'I3');
-SET &OT_STR = '`';
-REPEAT :Z1_LOOP FOR &I FROM 1 TO &Z1_LEN;
-SET &Z1_CHA = SUBSTR(&Z1_LEN, &Z1_STR, &I, &I, 1, 'A1');
-IF &Z1_CHA EQ &Z1_DLM THEN GOTO :Z1_OUT;
-SET &OT_STR = IF &OT_STR EQ '`' THEN &Z1_CHA ELSE &OT_STR | &Z1_CHA;
-GOTO :Z1_LOOP
-:Z1_OUT
-TYPE OT_STR --- &OT_STR
-SET &OT_STR = '`';
-:Z1_LOOP
-TYPE ---------------------------------------------------------
-RUN



Thank you , this works well !!


WebFOCUS 8

Windows, All Outputs