sponsored links

Collapse

Announcement

Collapse
No announcement yet.

editc and editw

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

  • editc and editw

    hello all,

    could anyone tell me what editc and editw does

    thx in advance
    sashi

  • #2
    Re: editc and editw

    Originally posted by sashimohan
    hello all,

    could anyone tell me what editc and editw does

    thx in advance
    sashi
    Sashi,

    Basically they format decimal data.

    edit code Y is for date so 042005 with edit code Y = 04/20/05
    the edit word to do the same format would be ' / / '

    examples
    Code:
    There are times when programmers need to convert numbers to characters. 
    I use %EditC built in function using edit code 'X'. 
    
    
    Example:
    
    1. Time 34233 (say 3.42.33 am); TextFd = %EditC(Time:'X') 
         Returns '034233' when TextFd is 6A.
    
    2. Number 123; TextFd = %EditC(Number:'X') Returns '000123'
    more info
    Code:
    Q. Can I modify the IBM-shipped edit codes 5 through 9, or is that not 
         permitted because an OS/400 program uses them? I want to use 
         edit code 9 to display a YYMMD date format from a six-digit field.
    
    A. Yes, you can modify edit codes 5 through 9 for your own purposes 
        although IBM predefines them. To work with edit descriptions, type 
        GO CMDEDTD at an AS/400 command line to display a list of the available 
        edit description commands. Note that you can't actually modify the edit 
        description; instead, you must delete it with the DLTEDTD command and 
        then create a new one with the CRTEDTD command. You can find more 
        information about creating user-defined edit descriptions in Application  
        Display Programming (SC41-5715).
    
    As an alternative to changing the user-defined edit descriptions, you might
    consider using edit words. Edit words provide maximum flexibility in creating 
    edit masks.
    found an edit word example program
    Code:
         FQPrint    O    F   80        Printer
    
         D Unedited        S              8S 2
         D Edited          S              8S 2
    
         D PhoneBefore     S             10S 0
         D PhoneAfter      S             10S 0
    
         C                   Eval      UnEdited = 567
         C                   Eval      Edited = 567
         C                   Except    first
         C                   Except    second
         C                   Except    third
         C                   Except    fourth
         C                   Except    fifth
         C                   Except    sixth
         C                   Except    seventh
         C                   Except    eighth
         C                   Except    ninth
    
         C                   Eval      UnEdited = 123456
         C                   Eval      Edited = 123456
         C                   Except    tenth
    
         C                   Eval      UnEdited = 567
         C                   Eval      Edited = 567
         C                   Except    eleventh
    
         C                   Eval      UnEdited = -567
         C                   Eval      Edited = -567
         C                   Except    twelvth
         C                   Except    thirteenth
    
         C                   Eval      UnEdited = 567
         C                   Eval      Edited = 567
         C                   Except    twelvth
         C                   Except    thirteenth
    
         C                   Eval      UnEdited = -567
         C                   Eval      Edited = -567
         C                   Except    fourteenth
    
         C                   Eval      PhoneBefore = 7145551212
         C                   Eval      PhoneAfter =  7145551212
         C                   Except    fifteenth
         C                   Except    sixteenth
    
         C                   Eval      UnEdited = 567
         C                   Eval      Edited = 567
         C                   Except    seventeent
    
         C                   Eval      UnEdited = 000000.07
         C                   Eval      Edited = 000000.07
         C                   Except    eighteenth
    
         C                   Eval      *InLr = *On
    
         OQPrint    E            First       1  1
         O                                           15 'UnEdited:  '
         O                       UnEdited
         O                                           45 'Edited:  '
         O                       Edited                 '        '
    
         OQPrint    E            Second         1
         O                                           15 'UnEdited:  '
         O                       UnEdited
         O                                           45 'Edited:  '
         O                       Edited                 '      .  '
    
         OQPrint    E            Third          1
         O                                           15 'UnEdited:  '
         O                       UnEdited
         O                                           45 'Edited:  '
         O                       Edited                 ' 0    .  '
    
         OQPrint    E            Fourth         1
         O                                           15 'UnEdited:  '
         O                       UnEdited
         O                                           45 'Edited:  '
         O                       Edited                 '0         .  '
    
         OQPrint    E            Fifth          1
         O                                           15 'UnEdited:  '
         O                       UnEdited
         O                                           45 'Edited:  '
         O                       Edited                 '      &  '
    
         OQPrint    E            Sixth          1
         O                                           15 'UnEdited:  '
         O                       UnEdited
         O                                           45 'Edited:  '
         O                       Edited                 '     *.  '
    
         OQPrint    E            Seventh        1
         O                                           15 'UnEdited:  '
         O                       UnEdited
         O                                           45 'Edited:  '
         O                       Edited                 '*         .  '
    
         OQPrint    E            Eighth         1
         O                                           15 'UnEdited:  '
         O                       UnEdited
         O                                           45 'Edited:  '
         O                       Edited                 '     $0.  '
    
         OQPrint    E            Ninth          1
         O                                           15 'UnEdited:  '
         O                       UnEdited
         O                                           45 'Edited:  '
         O                       Edited                 '$      .  '
    
         OQPrint    E            Tenth          1
         O                                           15 'UnEdited:  '
         O                       UnEdited
         O                                           45 'Edited:  '
         O                       Edited                 '   ,   .  '
    
         OQPrint    E            Eleventh       1
         O                                           15 'UnEdited:  '
         O                       UnEdited
         O                                           45 'Edited:  '
         O                       Edited                 '   ,   .  '
    
         OQPrint    E            Twelvth        1
         O                                           15 'UnEdited:  '
         O                       UnEdited
         O                                           45 'Edited:  '
         O                       Edited                 '        -'
    
         OQPrint    E            Thirteenth     1
         O                                           15 'UnEdited:  '
         O                       UnEdited
         O                                           45 'Edited:  '
         O                       Edited                 '        CR'
    
         OQPrint    E            Fourteenth     1
         O                                           15 'UnEdited:  '
         O                       UnEdited
         O                                           45 'Edited:  '
         O                       Edited                 '         Negative'
    
         OQPrint    E            Fifteenth      1
         O                                           15 'UnEdited:  '
         O                       PhoneBefore
         O                                           45 'Edited:  '
         O                       PhoneAfter             '   -   -    '
    
         OQPrint    E            Sixteenth      1
         O                                           15 'UnEdited:  '
         O                       PhoneBefore
         O                                           45 'Edited:  '
         O                       PhoneAfter             '0AREA&   &NO.&   -    '
    
         OQPrint    E            Seventeent     1
         O                                           15 'UnEdited:  '
         O                       UnEdited
         O                                           45 'Edited:  '
         O                       Edited                 '$      &DOLLARS&  &CTS'
    
         OQPrint    E            Eighteenth     1
         O                                           15 'UnEdited:  '
         O                       UnEdited
         O                                           45 'Edited:  '
         O                       Edited                 '$      &DOLLARS&  &CTS'
    Attached Files
    All my answers were extracted from the "Big Dummy's Guide to the As400"
    and I take no responsibility for any of them.

    www.code400.com

    Comment


    • #3
      Re: editc and editw

      I am having trouble forcing a positive/negative sign in front of a number on output using editw.
      Is there support for this?

      %trim(%editw($AmountVar:'- 0. '))
      $AmountVar = 999.99 => +999.99
      $AmountVar = -999.99 => -999.99

      Comment


      • #4
        Re: editc and editw

        Originally posted by itp View Post
        I am having trouble forcing a positive/negative sign in front of a number on output using editw.
        Is there support for this?



        $AmountVar = 999.99 => +999.99
        $AmountVar = -999.99 => -999.99
        Use %editc instead.


        %EDITC( $AMOUNTVAR : '1' : '+')
        Will float the "+" symbol to the left.


        %EDITC( $AMOUNTVAR : '1' : '-')
        Will float the "-" symbol to the left.


        I haven't tested this with these two symbols, but it should work. You wuold have to condition the variable to see if its positive or negative.


        Code:
         
        
        select;
        
          when $AmountVar > 0;
            %editc( $AmountVar : '1' : '+') ;
        
          when $AmountVar < 0;
            %editc( $AmountVar : '1' : '-') ;
        
          when $AmountVar = 0;
            %editc( $AmountVar : '1' );
        
        endsl;
        There might be a better way than this, such as creating a user defined edit code.
        Michael Catalani
        IS Director, eCommerce & Web Development
        Acceptance Insurance Corporation
        www.AcceptanceInsurance.com
        www.ProvatoSys.com

        Comment


        • #5
          Re: editc and editw

          www.rpglanguage.com/editcodes.html

          gives the editcodes which can be used with %editc.

          It also tells you which will give the minus sign on the left and on the right.
          John McKay
          jmckay@mckaysoftware.ie
          http://www.rpglanguage.com

          Comment

          sponsored links

          Collapse

          Working...
          X