ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

MOVEA *ALL in RPG/free

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

  • MOVEA *ALL in RPG/free

    I am trying to find a replacement in free format RPG for the MOVEA opcode to populate an entire string with the same character.

    Example: populate a 198 character field in a printer file with the equal sign (=).

    We have older code that looks like this. How can I do this is in /free?


    D UDL S 198 DIM(1)
    D UNL S 198A

    C MOVE *ALL'=' UDL
    C MOVEA UDL UNL

  • #2
    Re: MOVEA *ALL in RPG/free

    take a look at the %subarr() BIF...
    I'm not anti-social, I just don't like people -Tommy Holden

    Comment


    • #3
      Re: MOVEA *ALL in RPG/free

      I had looked at %subarr before but up until a few minutes ago I was having brain cramp getting it to work. Below are 2 examples that work. The second being that the arary is initialized and eliminated the need for the %subarr function at all.

      Code:
      d InString        ds            50                                        
      d Array                          1a   dim(50) overlay(InString:1)         
      d OutString       s             50a                                       
       /free                                                                    
          %subarr(Array:1:50) = '*' ;                                           
          OutString = %trimr(InString) ;                                        
                                                                                
                                                                                
      d InString        ds            50                                        
      d Array                          1a   dim(50) overlay(InString:1) inz('*')
      d OutString       s             50a                                       
       /free                                                                    
          OutString = %trimr(InString) ;
      Last edited by jamief; March 6, 2014, 08:29 AM.

      Comment


      • #4
        Re: MOVEA *ALL in RPG/free

        Originally posted by JCVTrigger View Post
        I am trying to find a replacement in free format RPG for the MOVEA opcode to populate an entire string with the same character.

        Example: populate a 198 character field in a printer file with the equal sign (=).
        Two methods:
        Code:
              * Method #1: Use D-Spec with initialization
             D myField         S            198A   Inz(*ALL'=')
              **************************************************
              * Method #2: assign in free format
              /FREE
                  myField = *ALL'=';
              /END-FREE
        I do this a lot (usually with dashes, sometimes with equals) and always use method #1. For me the field is called XDash198 which is self documenting. HTH
        http://www.linkedin.com/in/chippermiller

        Comment


        • #5
          Re: MOVEA *ALL in RPG/free

          Originally posted by Chipper View Post
          Two methods:
          Code:
                * Method #1: Use D-Spec with initialization
               D myField         S            198A   Inz(*ALL'=')
                **************************************************
                * Method #2: assign in free format
                /FREE
                    myField = *ALL'=';
                /END-FREE
          I do this a lot (usually with dashes, sometimes with equals) and always use method #1. For me the field is called XDash198 which is self documenting. HTH
          Method #1 is what i use. why bother with the extra hassle of using an array for this?
          I'm not anti-social, I just don't like people -Tommy Holden

          Comment

          Working...
          X