× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.


  • Subject: Re: Newby Trim question
  • From: booth@xxxxxxxxxxxx
  • Date: Fri, 11 Aug 2000 01:11:56 GMT

You want %EditC  or  %EditW

Help:

4.1.1.6 %EDITC (Edit Value Using an Editcode)




     %EDITC(numeric : editcode {: *ASTFILL | *CURSYM | currency-symbol}) 


This function returns a character result representing the numeric value 
edited according to the edit code. In
general, the rules for the numeric value and edit code are identical to 
those for editing numeric values in output
specifications. The third parameter is optional, and if specified, must be 
one of: 

*ASTFILL 
    Indicates that asterisk protection is to be used. This means that 
leading zeros are replaced with asterisks in
    the returned value. For example, %EDITC(0012.5 : 'K' : *ASTFILL) 
returns '***12.5-'. 

*CURSYM 
    Indicates that a floating currency symbol is to be used. The actual 
symbol will be the one specified on the
    control specification in the CURSYM keyword, or the default, '$'. When 
*CURSYM is specified, the currency
    symbol is placed in the the result just before the first significant 
digit. For example, %EDITC(0012.5 : 'K' :
    *CURSYM) returns ' $12.5-'. 

currency-symbol 
    Indicates that floating currency is to be used with the provided 
currency symbol. It must be a 1-byte
    character constant (literal, named constant or expression that can be 
evaluated at compile time). 




Float expressions are not allowed in the first parameter (you can use %DEC 

| to convert a float to an editable format). In the second parameter, the 
edit code is specified as a character
constant; supported edit codes are: 'A' - 'D', 'J' - 'Q', 'X' - 'Z', '1' - 
'9'. The constant can be a literal, named
constant or an expression whose value can be determined at compile time. 

 
__________________________________________________________________________________________________
 
 
   |                            | 
   |                            | 
   | 
DName+++++++++++ETDsFrom+++To/L+++IDc.Keywords+++++++++++++++++++++++++++  
                   | 
   |   D msg             S            100A                            | 
   |   D salary          S              9P 2                            | 
   |                            | 
   |    * If the value of salary is 2451.53, then the value of salary * 12 
                           | 
   |    * is 29418.36. The edited version of salary * 12 using the A edit  
                          | 
   |    * code with floating currency is ' $29,418.36 '.           | 
   |    * The value of msg is 'The annual salary is $29,418.36'         | 
   |                            | 
   | 
CL0N01Factor1+++++++Opcode&ExtExtended-factor2+++++++++++++++++++++++++++  
                   | 
   |   C                   EVAL      msg = 'The annual salary is '      | 
   |   C                                + %trim(%editc(salary * 12      | 
   |   C                                              :'A': *CURSYM))      
            | 
   |                            | 
   |    * If the value of salary is 2451.53, then the value of salary * 12 
                           | 
   |    * is 29418.36. The edited version of salary * 12 using the A edit  
                          | 
   |    * code with floating currency is ' $29,418.36 '.           | 
   |    * The value of msg is 'The annual salary is $29,418.36'         | 
   |   C                   EVAL      msg = 'The annual salary is '      | 
   |   C                                + %trim(%editc(salary * 12      | 
   |   C                                              :'A': '&'))       | 
   |                            | 
   |    * In the next example, the value of msg is 'Salary is 
$***29,418.36'                          | 
   |    * Note that the '$' comes from the text, not from the edit code.   
                        | 
   |   C                   EVAL      msg = 'Salary is $'           | 
   |   C                                + %trim(%editc(salary * 12      | 
   |   C                                               :'B': *ASTFILL))    
                     | 
   |                            | 
   |    * In the next example, the value of msg is 'The date is 
1996/06/27'                           | 
   |   C                   EVAL      msg = 'The date is '            | 
   |   C                                + %trim(%editc(*date : 'Y'))       
      | 
   |                            | 
   |                            | 
 
|__________________________________________________________________________________________________|
| 

   Figure 137. %EDITC Example 1 


A common requirement is to edit a field as follows: 

    Leading zeros are suppressed 

    Parentheses are placed around the value if it is negative 




The following accomplishes this using an %EDITC in a subprocedure: 

 
__________________________________________________________________________________________________
 
 
   |                            | 
   |                            | 
   | 
DName+++++++++++ETDsFrom+++To/L+++IDc.Keywords+++++++++++++++++++++++++++  
                   | 
   |   D neg             S              5P 2      inz(-12.3)   | 
   |   D pos             S              5P 2      inz(54.32)   | 
   |   D editparens      PR            50A                            | 
   |   D    val                        30P 2      value          | 
   |   D editedVal       S             10A                            | 
   | 
CL0N01Factor1+++++++Opcode&ExtExtended-factor2+++++++++++++++++++++++++++  
                   | 
   |   C                   EVAL      editedVal = editparens(neg)    | 
   |    * Now editedVal has the value '(12.30)   '     | 
   |   C                   EVAL      editedVal = editparens(pos)    | 
   |    * Now editedVal has the value ' 54.32    '     | 
   |                            | 
   |    *---------------------------------------------------------------   
                        | 
   |    * Subprocedure EDITPARENS                            | 
   |    *---------------------------------------------------------------   
                        | 
   |   P editparens      B                            | 
   |   D editparens      PI            50A                            | 
   |   D    val                        30P 2      value          | 
   |   D lparen          S              1A        inz(' ')             | 
   |   D rparen          S              1A        inz(' ')             | 
   |   D res             S             50A                            | 
   |                            | 
   |    * Use parentheses if the value is negative     | 
   |   C                   IF        val < 0                            | 
   |   C                   EVAL      lparen = '('    | 
   |   C                   EVAL      rparen = ')'    | 
   |   C                   ENDIF                            | 
   |                            | 
   |    * Return the edited value                            | 
   |    * Note that the '1' edit code does not include a sign so we       
| 
   |    * don't have to calculate the absolute value.        | 
   |   C                   RETURN    lparen             +            | 
   |   C                             %editc(val : '1')  +            | 
   |   C                             rparen                            | 
   |                            | 
   |   P editparens      E                            | 
   |                            | 
   |                            | 
 
|__________________________________________________________________________________________________|
| 

   Figure 138. %EDITC Example 2 
_______________________
Booth Martin
Booth@MartinVT.com
http://www.MartinVT.com
_______________________




a b <eagle_291@yahoo.com>
Sent by: owner-rpg400-l@midrange.com
08/10/2000 04:53 PM
Please respond to RPG400-L

 
        To:     RPG400-L@midrange.com
        cc: 
        Subject:        Newby Trim question

I currently have an application that moves a numeric
field into a char field, but not only does it move the
field it also moves the the leading zeros into the
character field.  Is there a way to remove the leading
and trailing zeros ?

Psuedo example::
   move  numeric  character
   move  112      00000112


Any help would be greatly appreciated


__________________________________________________
Do You Yahoo!?
Kick off your party with Yahoo! Invites.
http://invites.yahoo.com/
+---
| This is the RPG/400 Mailing List!
| To submit a new message, send your mail to RPG400-L@midrange.com.
| To subscribe to this list send email to RPG400-L-SUB@midrange.com.
| To unsubscribe from this list send email to RPG400-L-UNSUB@midrange.com.
| Questions should be directed to the list owner/operator: 
david@midrange.com
+---




+---
| This is the RPG/400 Mailing List!
| To submit a new message, send your mail to RPG400-L@midrange.com.
| To subscribe to this list send email to RPG400-L-SUB@midrange.com.
| To unsubscribe from this list send email to RPG400-L-UNSUB@midrange.com.
| Questions should be directed to the list owner/operator: david@midrange.com
+---

As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.