Topic
3 replies Latest Post - ‏2014-08-14T21:01:57Z by SeanScanlon
SeanScanlon
SeanScanlon
2 Posts
ACCEPTED ANSWER

Pinned topic %EDITC and %INT with rounding

‏2014-08-14T19:07:43Z |

Noticed the following. I would think the last two DSPLY's should show the same value, just wondering what I'm missing? 

 
D qty             s              9  2 inz(123.45)
D qtyTemp         s              9  0            
D qtyWrong        s              9               
D qtyRight        s              9               
                                                 
   qtyTemp  = %int(qty);                         
   dsply qtyTemp; 
                                                 
   qtyRight = %editc( qtyTemp : 'X' );           
   dsply qtyRight;                               
                                                 
   qtyWrong = %editc( %int(qty) : 'X' );         
   dsply qtyWrong;                               
                                                 
   *inlr = *on; 
Program outputs:
DSPLY        123
DSPLY  000000123
DSPLY  000000012                                                                          
                                                                                                                                    
                                                                                                                                    
                                                                                                                                    

                                                                                           

Updated on 2014-08-14T19:07:58Z at 2014-08-14T19:07:58Z by SeanScanlon
  • JonParis
    JonParis
    113 Posts
    ACCEPTED ANSWER

    Re: %EDITC and %INT with rounding

    ‏2014-08-14T19:43:52Z  in response to SeanScanlon

    You are missing the fact that the %INT() function is going to return a 10 digit response and therefore %EditC produces a 10 character string which is then truncated on the assignment.

    You can see this in play by doing the DSPLY directly with the results of the BIFs - like below - it produces [0000000123]:

    
    
    dsply ('[' + %editc( %int(qty) : 'X' ) + ']' );
    
    Updated on 2014-08-14T19:45:01Z at 2014-08-14T19:45:01Z by JonParis
  • barbara_morris
    barbara_morris
    382 Posts
    ACCEPTED ANSWER

    Re: %EDITC and %INT with rounding

    ‏2014-08-14T19:45:51Z  in response to SeanScanlon

    An integer has 10 digits, so the %EDITC of the %INT is 10 bytes long. qtyWrong is only 9 bytes long, so it's missing the final '3'.

    • SeanScanlon
      SeanScanlon
      2 Posts
      ACCEPTED ANSWER

      Re: %EDITC and %INT with rounding

      ‏2014-08-14T21:01:57Z  in response to barbara_morris

      Well now I feel silly, knew I was missing something simple. Thanks for the replies! 

      Updated on 2014-08-14T21:02:28Z at 2014-08-14T21:02:28Z by SeanScanlon