ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Free Form RPG

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

  • Free Form RPG

    I am trying to compile my first free form RPG program. See program below. I am getting these two error messages.
    *RNF0257 30 22 Form-Type entry for main procedure not valid or out of
    sequence.
    *RNF7023 40 1 The Compiler cannot determine how the program can end.

    I am on V5R3 and my source is RPGLE. Why doesn't the compiler understand the code is in free formatted RPG? How do I correct this.

    PHP Code:
    ********************************************************************              
     **  
    99 Bottles of Beer on the Wall *                                              
     * 
    Example Code courtesy of ...                                                    
     * [
    url]http://www.iseriesnetwork.com/Resources/ClubTech/TNT400/bo400ng/as400scmapi.htm[/url] 
     
    ********************************************************************              
    H dftactgrp(*no)                                                                   
    H actgrp(*caller)                                                                  
    D                 DS                                                               
    D idx                            2  0 inz
    (99)                                      
    D idxAlpha                       2A   overlay(idx:1)                               
    D F3              c                   x'33'                                        
    D sa_norm         c                   x'20'                                        
    D sa_highlight    c                   x'22'                                        
    D BeerLine1       s             30    inz(' Bottles of beer on the wall, ')        
    D BeerLine2       s             17    inz(' Bottles of beer ')                     
    D BeerLine3       s             32    inz('Take one down and pass it +             
    D                                     around'
    )                                     
    D ExitStr         s             43    inz('Press Enter to Continue or +            
    D                                     Press F3 to Exit'
    )                           
    D txt             s            128                           
    D txtlen          s              9b 0 inz
    (132)               
    D err             s              8    inz(x'0000000000000000'
    D aid             s              1                           
    D lines           s              9b 0 inz
    (1)                 
    D wf1             s              1                           
    D wrtn            s              9b 0                        
    D ClrScr          PR             9b 0 extproc
    ('QsnClrScr')   
    D  mode                          1    options(*nopass) const 
    D  cmdbuf                        9b 0 options(*nopass) const 
    D  env                           9b 0 options(*nopass) const 
    D  error                         8    options(*nopass)       
    D WrtDta          PR             9b 0 extproc('QsnWrtDta')   
    D  data                        128                           
    D  datalen                       9b 0                        
    D  fldid                         9b 0 options
    (*nopass) const 
    D  row                           9b 0 options(*nopass) const 
    D  col                           9b 0 options(*nopass) const 
    D  strmatr                       1    options(*nopass) const 
    D  endmatr                       1    options(*nopass) const 
    D  strcatr                       1    options(*nopass) const                            
    D  endcatr                       1    options(*nopass) const                            
    D  cmdbuf                        9b 0 options(*nopass) const                            
    D  env                           9b 0 options(*nopass) const                            
    D  error                         8    options(*nopass)                                  
    D GetAID          PR             1    extproc('QsnGetAID')                              
    D  aid                           1    options(*nopass)                                  
    D  env                           9b 0 options(*nopass) const                            
    D  error                         8    options(*nopass)                                  
    D RollUp          PR             9b 0 extproc('QsnRollUp')                              
    D  lines                         9b 0                  const                            
    D  top                           9b 0                  const                            
    D  bottom                        9b 0                  const                            
    D  cmdbuf                        9b 0 options(*nopass) const                            
    D  env                           9b 0 options(*nopass) const                            
    D  error                         8    options(*nopass)                                  
     ************************************************************************************** 
     *                          
    Mainline                                                    
     
    ************************************************************************************** 
     /
    FREE                                                                                  
      wrtn 
    ClrScr('4' err);                                 
      
    txt ExitStr;                                                    
      
    txtlen = %Len(txt);                                               
      
    wrtn WrtDta (txt txtlen :                         
             
    sa_norm sa_norm sa_highlight sa_highlight :          
             
    err);                                              
      for 
    idx 99 Downto 1;                                            
        
    txt idxAlpha BeerLine1 idxAlpha BeerLine2 BeerLine3;  
        
    txtlen = %Len(txt);                                             
        
    wrtn WrtDta (txt txtlen 26 :                      
               
    sa_norm sa_norm sa_norm sa_norm :                  
               
    err);                                            
         
    wf1 GetAID (aid err);                                  
        If 
    aid F3;                                                    
          
    Leave;                                                        
        EndIf;                                                          
        
    wrtn RollUp (lines 27 0err);                    
        endfor;                                                         
        *
    INLR = *ON;                                                    
     /
    END-FREE 

  • #2
    Re: Free Form RPG

    Check out this line its not complete
    D err s 8 inz(x'0000000000000000'

    this compiles and runs on my box v5r3m1

    PHP Code:
         H dftactgrp(*no)
         
    H actgrp(*caller)
         
    D                 DS
         D idx                            2  0 inz
    (99)
         
    D idxAlpha                       2A   overlay(idx:1)
         
    D F3              c                   x'33'
         
    D sa_norm         c                   x'20'
         
    D sa_highlight    c                   x'22'
         
    D BeerLine1       s             30    inz(' Bottles of beer on the wall, ')
         
    D BeerLine2       s             17    inz(' Bottles of beer ')
         
    D BeerLine3       s             32    inz('Take one down and pass it +
         D                                     around'
    )
         
    D ExitStr         s             43    inz('Press Enter to Continue or +
         D                                     Press F3 to Exit'
    )
         
    D txt             s            128
         D txtlen          s              9b 0 inz
    (132)
         
    D err             s              8    inz(x'0000000000000000')
         
    D aid             s              1
         D lines           s              9b 0 inz
    (1)
         
    D wf1             s              1
         D wrtn            s              9b 0
         D ClrScr          PR             9b 0 extproc
    ('QsnClrScr')
         
    D  mode                          1    options(*nopass) const
         
    D  cmdbuf                        9b 0 options(*nopass) const
         
    D  env                           9b 0 options(*nopass) const
         
    D  error                         8    options(*nopass)

         
    D WrtDta          PR             9b 0 extproc('QsnWrtDta')
         
    D  data                        128
         D  datalen                       9b 0
         D  fldid                         9b 0 options
    (*nopass) const
         
    D  row                           9b 0 options(*nopass) const
         
    D  col                           9b 0 options(*nopass) const
         
    D  strmatr                       1    options(*nopass) const
         
    D  endmatr                       1    options(*nopass) const
         
    D  strcatr                       1    options(*nopass) const
         
    D  endcatr                       1    options(*nopass) const
         
    D  cmdbuf                        9b 0 options(*nopass) const
         
    D  env                           9b 0 options(*nopass) const
         
    D  error                         8    options(*nopass)

         
    D GetAID          PR             1    extproc('QsnGetAID')
         
    D  aid                           1    options(*nopass)
         
    D  env                           9b 0 options(*nopass) const
         
    D  error                         8    options(*nopass)

         
    D RollUp          PR             9b 0 extproc('QsnRollUp')
         
    D  lines                         9b 0                  const
         
    D  top                           9b 0                  const
         
    D  bottom                        9b 0                  const
         
    D  cmdbuf                        9b 0 options(*nopass) const
         
    D  env                           9b 0 options(*nopass) const
         
    D  error                         8    options(*nopass)

          *=============================================================
          *  
    M A I N     L I N E
          
    *=============================================================

          /
    free

           wrtn 
    ClrScr('4' err);
            
    txt ExitStr;
            
    txtlen = %Len(txt);
            
    wrtn WrtDta (txt txtlen :
                   
    sa_norm sa_norm sa_highlight sa_highlight :
                   
    err);
            for 
    idx 99 Downto 1;
              
    txt idxAlpha BeerLine1 idxAlpha BeerLine2 BeerLine3;
              
    txtlen = %Len(txt);
              
    wrtn WrtDta (txt txtlen 26 :
                     
    sa_norm sa_norm sa_norm sa_norm :
                     
    err);
               
    wf1 GetAID (aid err);
              If 
    aid F3;
                
    Leave;
              EndIf;
              
    wrtn RollUp (lines 27 0err);
              endfor;
               *
    INLR = *ON;
          /
    end-free

    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: Free Form RPG

      I copies this down and have compiled it on v53r. One change:

      D txtlen s 9b 0 inz(132)
      D err s 8 inz(x'0000000000000000') <---- Close bracket
      D aid s 1

      Good Luck
      Bill
      Bill
      "A good friend will bail you out of jail,
      A true friend would be sitting beside you saying,
      'Wow, that was fun.'"

      Comment


      • #4
        Re: Free Form RPG

        Data area
        ....+... 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 ...+...
        /FREE

        Would it matter where I have my /FREE? I have it in my 7th position. I am on V5R3 too. Strange.

        Comment


        • #5
          Re: Free Form RPG

          Oh yes I see great minds think alike.
          Bill
          Bill
          "A good friend will bail you out of jail,
          A true friend would be sitting beside you saying,
          'Wow, that was fun.'"

          Comment


          • #6
            Re: Free Form RPG

            Originally posted by dcutaia View Post
            Data area
            ....+... 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 ...+...
            /FREE

            Would it matter where I have my /FREE? I have it in my 7th position. I am on V5R3 too. Strange.

            I copied it as is and had no problem. But yes it does make a difference where the /free starts.

            ..... *. 1 ...+... 2 .
            ****************
            123456/FREE
            123456wrtn = ClrScr('4' : 0 : 0 : err);

            I have it in 7 with no problem.
            Bill
            "A good friend will bail you out of jail,
            A true friend would be sitting beside you saying,
            'Wow, that was fun.'"

            Comment


            • #7
              Re: Free Form RPG

              *********************
              ======>a
              *RNF0257 30 a 005300 Form-Type entry for main procedure not valid or out of
              sequence.
              54 /FREE
              ======>a
              *RNF0257 30 a 005400 Form-Type entry for main procedure not valid or out of
              sequence.
              55 wrtn = ClrScr('4' : 0 : 0 : err);


              When I review my errors I noticed that I am getting 00530 on my first statement or /FREE. What position do I put the /FREE in?

              Comment


              • #8
                Re: Free Form RPG

                It starts in the seventh position.

                can you download the source I reposted and using iseries navigator place
                it back on your system and try that?

                jamie
                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

                Working...
                X