Convert Comma Delimited Numeric String to Quoted Zero Padded Character String
Input :-- &IPSTR='123,678,12,9,9999'; DESIRED OUTPUT :- &IPSTR='''0123','0678','0012','0009','9999'''; I have a fair idea of Code, but I am missing something or Misusing something... Can anyone help ?
Specific Problem ::- Function ATODBL below, does not seem to be printing a Number but continues to display a Character....
Here is my Code :- ========================================================================== -SET &IPSTR='123,678,12,9,9999'; -SET &OPSTR=' '; -SET &DSP = ' Displayed String : ';
-SET &I=1; -SET &TOK = '1'; -* Get Tokens in a loop -REPEAT :GETTOKENS WHILE &TOK NE ' '; -* obtain the first token -SET &TOK = GETTOK(&IPSTR,&IPSTR.LENGTH,&I,',',4,'A4'); -SET &DBLTOK = ATODBL(&TOK,4,'D4'); -SET &TOK = STRIP(4,&TOK,' ',&TOK); -SET &FMTTOK = EDIT(&DBLTOK,'''9999'''); -IF &TOK = ' ' THEN GOTO :GETTOKENS; -TYPE &I ||':' || &TOK || ' Len:' || &TOK.LENGTH || 'DBLTOK:' || &DBLTOK -SET &OPSTR= &OPSTR |',' |&FMTTOK; -SET &I = &I + 1; -:GETTOKENS
Tom, Your solution works !. Thanks for your prompt response. It got me thinking, and I have coded an alternate solution, which I think can be more generic.