EGL Development User Group

EGL Development User Group

EGL Development User Group

The EGL Development User Group is dedicated to sharing news, knowledge, and insights regarding the EGL language and Business Developer product. Consisting of IBMers, HCL, and users, this community collaborates to advance the EGL ecosystem.

 View Only
  • 1.  String Handling

    Posted 01/03/19 08:05 AM

    We've recently migrated from VAGen to EGL, so apologies if this is a stupid question.

    I'm trying to build up a string and it includes a numeric (WS-PACK-FACTOR):

     WS-PACK-FACTOR = 99; // Defined as NUM(5)

     WS-RESULT = VGLib.concatenateWithSeparator(WS-MAIL-1-LINE, WS-PACK-FACTOR,
                " ");

    But when displayed, it shows:

    Pack Factor: 00099   

    How do I get rid of the leading Zeroes?

    Thanks

     

     

    Toopster


  • 2.  Re: String Handling

    Posted 01/03/19 09:08 AM

    @Toopster 2bbd82a1-28e5-4d45-ba97-01ad07a04ac3

     

    see if the mathlib library can help with commands.

         mathlib.stringAsDecimal (value);
         mathlib.stringAsInt (value)

     

    @ojomenezes FACG092D666CC7481FC307811298B1000067

    ojomenezes


  • 3.  Re: String Handling

    Posted 01/04/19 09:46 AM

    @Toopster 2bbd82a1-28e5-4d45-ba97-01ad07a04ac3

    Ho about just using concatenation?

     

     

              WS-PACK-FACTOR  num(5) = 99;
              WS-MAIL-1-LINE String = "Pack Factor:";



             WS-RESULT  String;


             WS-RESULT = WS-MAIL-1-LINE + " " + WS-PACK-FACTOR;
    SysLib.writeStdout(WS-RESULT);
      

     

    mdevb


  • 4.  Re: String Handling

    Posted 01/07/19 07:23 AM

    Hi,

    We now have in egl a modern concatenation operator you can use the + or double sign :: and much better than the old VGLib.concatenateWithSeparator function. But unfortunately in the migration from VAG to EGL this is not converted. So for your new programs use one of these operators I always prefer the double :: not to confuse math operation +.

    I do not know why your test is displaying zeros on the left, probably your EGL Build Option has some difference with mine. You can attach your EGL Build Option for review.

    This is my sample program:

     

    package teste1;
     
     
    program lab1 type BasicProgram {}
     
    a, b int?;
     
    aNum NUM(9,2);
    bCHA char(50);
    cSTR string;
    tTXT char(50);
     
     
    function main()
     
    aNUM = 1234.56;
    tTXT = "Hello: ";
     
    //* Concate with field type CHAR
    bCHA = tTXT;
    bCHA = clip(bCHA) :: " " :: aNUM; // you need to use the clip function to remove blank to CHAR fields
    sysLib.writeStdout(bCHA);
     
    //* Concate with field type STRING
    cSTR = tTXT;
    cSTR = cSTR :: " " :: aNUM; // STRING fields ever remove blanks.
    sysLib.writeStdout(cSTR);
     
    bCHA = tTXT;
    bCHA = VGLib.concatenateWithSeparator(bCHA, aNUM, " ");
    sysLib.writeStdout(cSTR);
                
    end
     
    end
    Hsieh