Focal Point
[SOLVED] Tokenizing

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

October 20, 2008, 07:14 AM
<Navin>
[SOLVED] Tokenizing
I have the string like 987,654,321 i want to convert this to 987','654','321 .

How to convert this?
My String length will be differenat at run time . But the comms place is static , 3rd position only

Can we use this without GETTOK ??

Thanks
Naveen.

This message has been edited. Last edited by: Kerry,
October 20, 2008, 10:49 AM
Francis Mariani
Try the String Replace function to replace , with ','.

STRREP: Replacing Character Strings


Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
October 23, 2008, 03:00 AM
Ajai
Navin,

This may help you :
  
-SET &IN_VAL='456,232,232,2323,2323,23232,456,77676,56666';
-DEFAULT &CTR=0;
-DEFAULT &COUNTER =0;
-REPEAT ENDREPEAT WHILE &COUNTER NE 100
END
-SET &COUNTER = &COUNTER +1;
-SET &Var1=GETTOK(&IN_VAL,&IN_VAL.LENGTH,&COUNTER,',',40,'A40');
-IF &Var1 NE '' THEN LOOP1 ELSE GOTO LOOPEND;
-LOOP1
-SET &CTR = &CTR + 1;
-LOOPEND
-ENDREPEAT


-DEFAULT &COUNTER1 =0;
-DEFAULT &VALUE=' ';
-DEFAULT &NEW_VAL='';
-REPEAT ENDREPEAT1 WHILE &COUNTER1 LT &CTR
END
-SET &COUNTER1 = &COUNTER1 +1;
-SET &Var2=GETTOK(&IN_VAL,&IN_VAL.LENGTH,&COUNTER1,',',10,'A10');

-SET &VALUE = &VALUE |TRUNCATE(&Var2) |'","';
-SET &NEW_VAL=CTRAN(&VALUE.LENGTH,&VALUE,34,39,A400);
-TYPE &NEW_VAL


Thanks


WebFOCUS 7.1.4,Linux,
HTML,PDF,Excel,CSV
October 23, 2008, 05:28 AM
Surenther
Check This Code

quote:
-SET &IN_VAL='456,232,232,2323,2323,23232,456,77676,56666';
-SET &VALUE = STRREP(100,&IN_VAL,1,',',4,''',''',100,A100);
-TYPE &VALUE


thanks Allen


----------------------------------
Prod Version:WebFocus 8.1.05,OS:Unix ,Output:ALL
October 26, 2008, 05:02 PM
Waz
Navin, is this string a single field in a report or are the groups of 3 digits multiple fields ?


Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.07OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!

November 02, 2008, 11:59 PM
<Navin>
This Issue is solved . .

We got it using ,
STRREP(100,&CUSIP_VAL,1,',',4,''',''',800,A800);

Thanks all for your support.
January 04, 2012, 06:42 PM
Doug
Francis,

Thanks for the refresher on STRREP. This is one of those command names that I just could not remember.

I needed to change the commas in a list of user ids to ", @something.com" to fillout the list of email addresses. the techniques worked like a charm.

Good One