Results 1 to 5 of 5

Thread: editc and editw

  1. #1
    Code400 Newbie sashimohan's Avatar
    Join Date
    Feb 2005
    Location
    india
    Age
    33
    Posts
    29
    Rep Power
    0

    editc and editw

    hello all,

    could anyone tell me what editc and editw does

    thx in advance
    sashi

  2. # 666
    Circuit advertisement
    Join Date
    Aug 1965
    Location
    Yakutsk, Russia
    Age
    21
    Posts
    1,000,000
     

  3. #2
    Driver of cars, eater of food jamief's Avatar
    Join Date
    Jan 2004
    Location
    Belvidere, IL - United States of America
    Age
    49
    Posts
    9,416
    Rep Power
    12605

    Re: editc and editw

    Quote 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 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

  4. #3
    Administrator itp's Avatar
    Join Date
    Feb 2006
    Location
    Canada, eh
    Posts
    569
    Rep Power
    1963

    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

  5. #4
    Lord of the Dance
    Join Date
    Aug 2008
    Location
    Memphis - Nashville TN
    Posts
    1,692
    Rep Power
    4709

    Re: editc and editw

    Quote 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.

  6. #5
    Analyst
    Join Date
    Jul 2007
    Location
    Ireland
    Posts
    192
    Rep Power
    764

    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.

  7. # 666
    Circuit advertisement
    Join Date
    Aug 1965
    Location
    Yakutsk, Russia
    Posts
    1,000,000
     

Facebook Comments


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •