ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

minus sign in a packed field

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • minus sign in a packed field

    Does anyone know how I can send a negative sign(minus) sign to a packed field that is 18.2.
    For example instead of 0000000000000014.4P
    I want -000000000000014.43

    Thanks
    DAC

  • #2
    with this code :
    A18a=%Trim(%EDITC(MIN1IP:'X')); //INV PAYMENT /5
    I am getting:
    0000000000000014.4P
    if I need it -000000000000014.43
    should I try this %EDITC
    A18a=%Trim(%EDITC(MIN1IP:'N')); //INV PAYMENT /5

    Comment


    • #3
      This is a weird format you're looking to produce. this is not a normal format that I've seen people use. Since what you're looking for is rather uncommon, you may have to write a (very simple) routine to do the formatting for you rather than using a simple %EDITC.

      Comment


      • #4
        What about something like this?

        Code:
        dcl-s  A18a    char(20);
        dcl-s  Min1IP  packed(18:2);
        
        Min1IP = -14.43;
        
        A18a = %editw(Min1IP: '0                .  ');
        
        if Min1IP >= *zero;
           %subst(A18a:1:1) = *zero;
        else;
           %subst(A18a:1:1) = '-';
        endif;

        Comment


        • #5
          I would expect -000000000000014.43 to have packed character value of '0000000000000014.4L' not '0000000000000014.4P'.
          Letters J to S represent -1 to -9 (hex D1 to D9) and } for -0 (hex D0).

          Ringer

          Comment

          Working...
          X