H*------------------------------------------------------------------- H* H* The following program illustrates free-form coding using PDL. H* H* A table of PDL diagnostic messages is included. H* H* Review this program as needed to identify specific coding examples. H* H* H F* Copyright 1979, UNIQUE WORK ENTERPRISES F* F* This member contains explanations and examples of RPG F* PDL-precompiler code. F* +F* COPY EXAMPL SELECT-F .Generate file specifications +E* COPY EXAMPL SELECT-E .Generate extension specificationa +I* COPY EXAMPL SELECT-I .Generate input specifications C/EJECT C* Section A - Statement format C* C* For SYS/36 users, precompiler formats are pre-defined using C* SEU formats. Use command "PDLS" and CMD-3 to review SEU C* formats 31 TO 37 (7 Levels of indentation are defined for C* RPG calculation statements. Formats 38-39 may be used for C* coding pre-compiler external data definition macro C* statements. C* C* Pre-compiler calculation statements are identified by coding C* "+C*" in positions 5-7 of an RPG statement. For macro C* definition and generation of non-calculation statements, C* code a "+" in postion 5, the appropriate form type C* (F,E,I, or O) in position 6, and an "*" in position 7. C* For statements that do not need to be reformatted C* by the precompiler, use standard RPG coding rules. C* C* C* Section B - General coding rules: C* C* B1. Code any RPG Calculation in "PDL" Free-form by stating C* factor-1,the verb,factor-2,and the result field in the same C* order as they would appear in a standard RPG statement. C* Each word in a precompiler statement must be separated C* from the next word by one(1) or more blanks. For macro C* generation (copy function), to indicate the absence C* (default) of a positional paramter within a paramter list, C* code a comma ( , ) preceded and followed by at least one C* blank in place of the parameter to be defaulted. C* C* B2. To define a field within a calculation statement, state C* the field length and decimal positions as a word following C* the result field. One or more blanks must separate the C* result word from the length word. For alphabetic fields, C* the length word will consist of a number (1 to 256). C* for numeric fields, the length word will be a number C* (1 to 15) follwed immediately by a period (.) Follwed by a C* single digit (0 to 9) indicating the number of decimal C* positions within the field.(EX: 5.0) C* C* B3. To set an indicator with the result of an RPG calculation, C* code a conditional keyword (EQ- NE- P- M- see table below) C* followed by the indicator to be set. A hyphen must connect C* the conditional keyword with the indicator. Only one C* conditional word (keyword-indicator) may be specified on a C* precompiler RPG calculation statement. The conditional C* word should be placed after the last word in the RPG C* statement (factor 2, the result field, or the length word). C* C* B4. Comments may be placed after the last word on any C* precompiler statement by coding a period (.) immediately C* followed by any alphabetic character. C* C/EJECT C* C* Section C - Special precompiler verbs. C* C* C1. MACRO: Macro refers to a sequence of RPG statements that C* are stored for use by issuing a macro "copy" C* function. Each "copy" function generates the C* pre-defined sequence of RPG statements varying C* positional parameters as specified by the "copy" C* statement. Macros may be library members of the C* "macro" library or may be defined within an RPG C* program for use within that program only. C* C* MACRO: macroname MACRO parm1 parm2 ... parm9 C* indicates that a program macro definition will C* follow, assigns macro name and default parm values. C* C* C2. MEND: MEND (no parameters required) C* indicates the end of a program macro definition C* C* C3. COPY: {COPY} macroname {parm1 parm2 ... parm9} C* generates the program- or library-macro named C* C* COPY: COPY macroname SELECT-x {USING parm1 parm2...parm9} C* generates statements from the named macro that C* have a form type (pos. 6) Equal to the "select" C* value (x). C* C* COPY: COPY macroname PREFIX-x {USING parm1 parm2...parm9} C* generates input or output macro statements setting C* the field name prefix (pos. 53 I/P, pos 32 O/P) C* equal to the prefix value (x). C* C* C4. EXCPT: EXCPT in1 in2 ... in9 C* generates an RPG EXCPT statement preceded by an C* RPG SETON statement and followed by an RPG SETOF C* statement for the indicators specified. C* C* C5. LEVEL: LEVEL level {USING in1 in2 in3} C* sets pos 6-7 of all RPG calculation statements C* that follow equal to the level value (ex lr). C* if the "using" phrase is present, precompiler work C* indicators will be set equal to the in1 in2 and C* in3 values. C* C* C6. SETOF: SETOF in1 in2 ... in9 OR in1 TO in2 C* sets off indicators/range of indicators specified. C* C* C7. SETON: SETON in1 in2 ... in9 OR in1 TO in2 C* sets on indicators/range of indicators specified. C* C* C8. LOKUP: Search LOKUP array EQ-in USING index 9.9 C* generates Z-ADD to initialize index and C* array type LOKUP. If no "using" keyword C* is specified, generates normal LOKUP. C* C/EJECT C* C* Section D - PDL Structured Logic Coding Rules C* C* D1. General Notes- C* C* (It is asumed that the reader is familiar with C* structured programming concepts, especially block- C* structure logic formats for sequence, selection, and C* iteration structures.) C* C* All PDL structures employ the RPG verbs "COMP", "TESTB", C* "TESTZ", "LOKUP", "CHAIN", or "READ" as well as "GOTO" C* and "TAG" statements to implement the logic requested. C* C* All PDL structures have a header statement ("IF", C* "SELECT", "LOOP", OR "DO") and a terminating statement C* ("ENDIF", "ENDSEL", "ENDLOOP", and "ENDDO"). C* C* Each structure has a unique set of intermediate C* statements that may be specified: ("ELSEIF", "ELSE", C* "CASE", "EXITIF"). C* C* In general, logic is expressed on precompiler statements C* ("IF", "ELSEIF", "SELECT", "CASE", "DO", "EXIXIF") C* in one of two formats: indicator tests or field tests. C* C* - Indicator tests are coded by stating an indicator C* followed by a status-word ("ON" / "OFF"). A hyphen C* must connect the indicator with the status-word. C* (EXAMPLE: 01-ON). C* (EXAMPLE: 02-OFF). C* C* - Field test logic has two basic formats: relational and C* verb format. C* C* - Relational field tests are coded by placing a c* relational word (EQ NE GT LT GE LE) between two C* valid RPG factors (FIELD NAME or LITERAL). C* (Example: FIELDA EQ FIELDB). C* (Example: FIELD1 GE 1 ). C* C* - Verb format field test logic consists of an RPG C* verb statement follwed by a conditional word C* (see table below of valid conditional words). C* (Example: TESTB '2' FIELDA MIXED) C* (Example: TESTZ FIELDB X ) C* (Example: FIELDA LOKUP ARA EQ ) C* (Example: FIELDA LOKUP ARA EQ-98 USING X) C* (Example: FIELDA LOKUP TABA TABB EQ) C* (Example: READ ISFILE2 EOF ) C* (Example: FIELDA CHAIN ISFILE F ) C* C* In general, statements that contain an expression of C* logic may be continued on the next statement by placing C* a logical connector ("AND" / "OR") after the last word C* (before any comments) in the statement. C/EJECT C* C* Section D - PDL Structured Logic Coding Rules (continued) C* C* D2. "IF" Structure. C* C* The "IF" structure implements the structured programming C* Selection structure for "IF/THEN/ELSE" Logic. C* C* The "IF" structue starts with an "IF" statement and must C* end with an "ENDIF" Statemtnt. Multiple "ELSEIF" C* statements and one "ELSE" statement may occur C* within the "IF" structure. C* Example: C* +C* IF FIELDA EQ FIELDB +C* MOVE 'A' TO WBYTE +C* ELSEIF FIELD1 EQ FIELD2 +C* MOVE 'B' TO WBYTE +C* ELSE +C* MOVE 'C' TO WBYTE +C* ENDIF C* C* The "ELSE" statement may contain an RPG verb or comments C* The "ENDIF" statement may only contain comments. C* C* The "IF" and "ELSEIF" statements may be continued C* using single level Boolean logic by placing either C* of the words "AND" or "OR" as the last word in the C* statement to be continued. Indicator tests have a C* limit of 8 continuation statements, there is no limit C* on the number of field test continuation statements. C* Example: C* +C* IF FIELDA EQ FIELDB OR +C* FIELD1 EQ FIELD2 +C* MOVE 'B' TO WBYTE +C* ENDIF C* C* Caution: thorough knowledge of precompiler C* generated code is required before combining C* "AND" continuation lines with "OR" lines. C/EJECT C* C* Section D - PDL Structured Logic Coding Rules (continued) C* C* D3. "SELECT-CASE" Structure C* C* The "SELECT-CASE" structure implements the structured C* programming selection structure for "IF/THEN/ELSE" C* logic in which multiple "ELSEIF" logic is required. C* C* The "SELECT-CASE" structure employs the same verbs C* as the "IF" structure and is intended for use when the C* required logic is a form of multiple choice. Note C* That cases are tested for the "TRUE" condition in the C* the order in which they appear within the 'SELECT-CASE" C* structure. That is if two case-statements are both C* "TRUE", The first "TRUE" case within the structure will C* BE EXECUTED. C* C* The "SELECT-CASE" structure starts with a "SELECT" C* statement and must end with an "ENDSEL" statement. C* a maximum of 50 "CASE" statements may occur within C* The "SELECT-CASE" structure. C* Example: C* +C* SELECT-CASE FIELD1 EQ +C* CASE 1 .FIELD1 IS EQUAL 1 +C* MOVE 'A' TO WBYTE +C* CASE 2 .FIELD1 IS EQUAL 2 +C* MOVE 'B' TO WBYTE +C* CASE DEFAULT .FIELD1 IS NONE OF THE ABOVE +C* MOVE 'D' TO WBYTE +C* ENDSEL C* C* The "CASE" statement may contain up to 14 C* field-names, constants, or indicators which are C* used in an "OR" relationship when deciding whether C* or not to execute the "CASE". C* C* Note the use of the reserved word "DEFAULT" C* on the last "CASE" statement. This "CASE" is C* executed when no other "CASE" is true. C* C* No parameters are processed for the "ENDSEL" C* statement. Only comments are allowed. C* C* The "SELECT-CASE" structure has four (4) formats: C* -Indicator status selection C* -Field relation selection (eq lt gt le ge) C* -Compare/verb "HI/LO/EQ" selection C* -Separate verb format selection. C* The format is determined by the "select-case" C* statement as shown in the following examples. C* C* Indicator status selection (note the reserved word "RPG") +C* SELECT-CASE RPG +C* CASE 01 03 .True if indicator 01 or 03 ON +C* MOVE 'A' TO WBYTE +C* CASE 02 .True if indicator 02 ON +C* MOVE 'B' TO WBYTE +C* CASE N01N03 .True if 01 and 03 are OFF +C* MOVE 'A' TO WBYTE +C* CASE 02+03 .True if 02 and 03 are ON +C* MOVE 'B' TO WBYTE +C* ENDSEL C* C* Field relation selection (note the relational word Ex:"EQ") C* (Also recognizes "NE" "GT" "LT" "GE" "LE") C* +C* SELECT-CASE FIELD1 EQ .Factor1 is field1 +C* CASE 1 .Factor2 is Literal1 +C* MOVE 'A' TO WBYTE +C* CASE 2 .Factor2 is literal2 +C* MOVE 'B' TO WBYTE +C* CASE FIELD2 .Factor 2 is field2 +C* MOVE 'B' TO WBYTE +C* ENDSEL C* C* Compare/verb HI/LO/EQ ("TO" indicates use of "COMP") C* +C* SELECT CASE FIELD1 TO 3 .Field1 Comp 3 +C* CASE HI +C* MOVE 'A' TO WBYTE +C* CASE LO +C* MOVE 'B' TO WBYTE +C* CASE EQ +C* MOVE 'C' TO WBYTE +C* ENDSEL C* C* C* Compare/verb HI/LO/EQ ("TESTZ" Indicates verb HI/LO/EQ format) C* +C* SELECT CASE TESTZ FIELDA .Test the zone of fielda +C* CASE X +C* MOVE 'A' TO WBYTE +C* CASE Y +C* MOVE 'B' TO WBYTE +C* CASE Z +C* MOVE 'C' TO WBYTE +C* ENDSEL C* C* Compare/verb HI/LO/EQ ("TESTB" indicates use of HI/LO/EQ verb) C* +C* SELECT CASE TESTB '123' WBYTE .test bits 123 in wbyte +C* CASE ON +C* MOVE 'A' TO WBYTE +C* CASE OFF +C* MOVE 'B' TO WBYTE +C* CASE MIXED +C* MOVE 'C' TO WBYTE +C* ENDSEL C* C* Separate verb (indicated by absence of any reserved word) C* +C* SELECT-CASE +C* CASE 1. TESTB '0' WBYTE ON +C* MOVE 'A' TO FIELDA +C* CASE 2. FIELD1 EQ FIELD2 +C* MOVE 'B' TO FIELDA +C* CASE 3. TESTZ WBYTE 1 X OR +C* TESTZ WBYTE Y +C* MOVE 'C' TO FIELDA +C* ENDSEL C/EJECT C* C* Section D - PDL structured logic coding rules (continued) C* C* D4. "DO" Structure. C* C* The "DO" structure implements the structured programming C* iteration structure for "DO-WHILE/DO-UNTIL" logic. C* C* The "DO" structure employs the same verbs as C* The "IF" structure and is intended for use when the C* required logic is iterative in nature. C* The "DO" structure starts with a "DO" statement C* and must end with an "ENDDO" statement. C* The "EXITIF" statement may occur any number of times C* within the "DO" structure. C* Example: C* +C* DO 3 TIMES USING X 2.0 .Use x as in index +C* EXCPT 51 +C* EXITIF ARA,X GT '4' +C* EXITIF ARA,X GT '4' ANDDO EXCPT 51 +C* EXITIF 01-ON +C* EXITIF 01-ON ANDDO SETOF 01 03 05 TO 10 +C* MOVE 'B' TO WBYTE +C* ENDDO C* C* The "EXITIF" statement is coded following the C* rules for the "IF" statement. When the condition C* tested is true, an exit is made from the "DO" structure. C* also, a single RPG statement may be executed prior to C* exiting from the "DO" structure by coding the reserved C* word "ANDDO", followed by an RPG statement, after the C* last word in the "EXITIF" statement. C* C* No parameters are processed for the "ENDDO" C* statement. Only comments are allowed. C* C* The "DO" structure has four (4) formats: C* -DO-WHILE a condition is true C* -DO-UNTIL a condition is true C* -DO TIMES: repeat a specified number of times C* -DO FROM/BYTO: repetition using FROM,BY,TO values. C* An index will be maintained by the "DO" structure C* logic for the "TIMES" and "FROM-TO" formats if C* The reserved word "USING" (followed by a numeric field C* name) is present on the "DO" statement. C* The format of the "DO" structure is determined by C* The "DO" statement as shown in the following examples. C* C* DO-WHILE format (indicated by the reserved word "WHILE") C* +C* DO WHILE FIELDA EQ FIELDB AND +C* FIELD1 LE 10 +C* MOVE 'A' TO FIELDA +C* ENDDO C* C* DO-UNTIL format (indicated by reserved word "UNTIL") C* +C* DO UNTIL FIELDA EQ 'XXXXX' OR +C* FIELDA EQ 'YYYYY' +C* MOVE 'A' TO FIELDB +C* ENDDO C* C* C* DO-WHILE format (indicated by the reserved word "WHILE") C* +C* DO WHILE 01-ON AND +C* 02-OFF +C* MOVE 'A' TO FIELDA +C* ENDDO C* C* DO-UNTIL format (indicated by reserved word "UNTIL") C* +C* DO UNTIL 10-ON OR +C* 11-ON +C* MOVE 'A' TO FIELDB +C* ENDDO C* C* DO-TIMES format (indicated by reserved word "TIMES") C* +C* DO 3 TIMES USING X 2.0 +C* MOVE 'A' TO ARA,X +C* ENDDO C/EJECT C* C* SECTION D - PDL Structured Logic Coding Rules (continued) C* C* D5. "LOOP" Structure. C* C* The "LOOP" Structure implements the structured C* programming iteration structure for "DO-WHILE/DO-UNTIL" C* logic when the "WHILE/UNTIL" condition is tested within C* the structure only. C* C* The "LOOP" structure employs the same verbs as C* The "IF" structure and is intended for use when the C* required logic is iterative in nature. C* The "LOOP" structure starts with a "LOOP" statement C* and must end with an "ENDLOOP" statement. C* The "EXITIF" statement must occur at least once C* within the "LOOP" structure. C* Example: C* +C* LOOP +C* READ ISFILE2 EOF-98 +C* EXITIF 98-ON +C* EXCPT 51 +C* ENDLOOP C* C* The "EXITIF" statement is coded following the C* rules for the "IF" statement. When the condition C* tested is true, an exit is made from the "LOOP" C* structure. C* C* No parameters are processed for the "LOOP" or C* "ENDLOOP" statements. Only comments are allowed. C/EJECT C* C* Section E - Table of valid conditional keywords. C* C* For TESTZ statements C* Y 12-ZONE C* NY NOT 12-ZONE C* X 11-ZONE C* NX NOT 11-ZONE C* Z 0-ZONE C* NZ NOT 0-ZONE C* C* For COMPARE and LOKUP operations C* NE NOT EQUAL C* EQ EQUAL C* LT LESS THAN C* GT GREATER THAN C* LE LESS THAN OR EQUAL C* GE GREATER THAN OR EQUAL C* C* For TESTB operations C* MIXED Mixed status, some on, some off C* ON All on status C* OFF All off status C* NMX Not mixed status, either all on or all off C* NON Not on status, either all off or mixed C* NOFF Not off status, either all on or mixed C* C* For CHAIN operations C* F RECORD FOUND C* NF RECORD NOT FOUND C* C* For READ operations C* EOF END OF FILE OCCURRED ON READ C* NEOF RECORD HAS BEEN READ, NO END OF FILE HAS OCCURED C* C* For ARITHMETIC operations C* P RESULT IS POSITIVE C* NP RESULT IS NOT POSITIVE C* Z RESULT IS ZERO C* NZ RESULT IS NOT ZERO C* M RESULT IS (MINUS) NEGATIVE C* NM RESULT IS NOT (MINUS) NEGATIVE C* C/EJECT C* Section F - Examples for sections A Through E. C* C* Compile this program to see the generated code C* Note : Statements generated by the precompiler will C* print with a hyphen preceding the form type (pos 6). C* sequence numbers printed in positions 1-4 of C* these statements will refer to the sequence number C* of the originating source statement prior to the C* pre-compile process. C* C* C* The following table illustrates all possible formats C* for the "IF" statement. These formats may also be used C* for the "ELSEIF" statement. Note that when combining C* statements (or/and) indicator tests should not be C* combined with field tests. C* C* Indicator logic: (-ON -OFF) +C* IF 01-ON +C* IF 01-OFF +C* IF 01-ON AND .Simple "AND" Logic +C* 02-OFF +C* IF 01-OFF OR .Simple "OR" Logic +C* 02-ON C* C* Closing ENDIF-S for preceding examples +C* EXITALL C* +C* ENDIF +C* ENDIF +C* ENDIF +C* ENDIF C* C* Once per program logic C* +C* IF FIRST-CYCLE .First cycle logic used +C* IF FIRST-90 .First indicator logic used +C* IF FIRST-1 .For program initialization C* .... .and to govern once only +C* IF FIRST-7 .functions such as halts C* C* CLOSING ENDIF-S FOR PRECEDING EXAMPLES C* +C* ENDIF +C* ENDIF +C* ENDIF +C* ENDIF C* C* Field relation logic: (EQ NE GT LT GE LE) C* +C* IF FIELDA EQ FIELDB +C* IF FIELDA NE FIELDB OR +C* FIELD1 LT FIELD2 +C* IF FIELDA GE 'A' AND +C* FIELDA LE 'Z' C* C* Closing ENDIF-S for preceding examples C* +C* ENDIF +C* ENDIF +C* ENDIF C* C* TESTB logic: (ON OFF MIXED NON NOFF NMX) C* +C* IF TESTB '0' WBYTE ON +C* IF TESTB '015' WBYTE MIXED AND +C* FIELD1 EQ FIELD2 +C* IF TESTB '7' WBYTE OFF OR +C* FIELD1 NE FIELD2 C* C* Closing ENDIF-S for preceding examples C* +C* ENDIF +C* ENDIF +C* ENDIF C* C* TESTZ logic (Y = 12-ZONE, X = 11-ZONE, Z = 0-ZONE) C* +C* IF TESTZ WBYTE X 2.0 +C* IF TESTZ WBYTE Y OR +C* TESTZ WBYTE Z +C* IF TESTZ WBYTE NX C* C* Closing ENDIF-S for preceding examples C* +C* ENDIF +C* ENDIF +C* ENDIF C* C* LOKUP verb format logic C* +C* IF FIELDA LOKUP TABSMP LE +C* IF WBYTE LOKUP ARA .Default EQ) +C* IF WBYTE LOKUP ARA EQ-98 USING X 2.0 +C* IF FIELDA LOKUP TABSMP TABRSL EQ AND +C* TABRSL GT FIELDB C* C* Closing ENDIF-S for preceding examples C* +C* ENDIF +C* ENDIF +C* ENDIF +C* ENDIF C* C* CHAIN verb logic: (F = Found, NF = Not-Found) C* +C* IF FIELDA CHAIN ISFILE F +C* IF FIELDA CHAIN ISFILE NF AND +C* FIELDA COMP 'A' EQ-98 +C* IF FIELDA CHAIN ISFILE F AND +C* FIELDA EQ 'A' C* C* Closing ENDIF-S for preceding examples C* +C* ENDIF +C* ENDIF +C* ENDIF C* C* READ verb logic: (EOF = END-OF-FILE, NEOF= Record read) C* +C* IF READ ISFILE2 EOF +C* IF READ ISFILE2 NEOF +C* IF READ ISFILE2 NEOF AND +C* TESTZ WBYTE Z C* C* Closing ENDIF-S for preceding examples C* +C* ENDIF +C* ENDIF +C* ENDIF C* C* C* DO-FROM-BY-TO (Indicated by reserved word "FROM") C* +C* DO FROM 3 TO 10 BY 2 USING X 2.0 +C* IF FIELDA EQ FIELDB +C* MOVE 'A' TO WORK1 1 +C* EXITDO +C* ENDIF +C* MOVE 'X' TO ARA,X +C* ENDDO C* C* C* DO-TIMES format (indicated by reserved word "TIMES") C* +C* DO 3 TIMES USING X 2.0 WHILE FIELDA EQ FIELDB +C* MOVE 'A' TO ARA,X +C* ENDDO C* C* DO-FROM-BY-TO (Indicated by reserved word "FROM") C* +C* DO FROM 3 TO 10 BY 2 USING X 2.0 WHILE 10-OFF +C* IF FIELDA EQ FIELDB +C* MOVE 'A' TO WORK1 1 +C* EXITDO +C* ENDIF +C* MOVE 'X' TO ARA,X +C* ENDDO C* C* C* DO-TIMES Format (indicated by reserved word "TIMES") C* +C* DO 3 TIMES USING X 2.0 UNTIL FIELDA GT FIELDB +C* MOVE 'A' TO ARA,X +C* ENDDO C* C* DO-FROM-BY-TO (Indicated by reserved word "FROM") C* +C* DO FROM 3 TO 10 BY 2 USING X 2.0 UNTIL 10-ON +C* IF FIELDA EQ FIELDB +C* MOVE 'A' TO WORK1 1 +C* EXITDO +C* ENDIF +C* MOVE 'X' TO ARA,X +C* ENDDO C* C/EJECT C* Section G - Examples of rpg operation codes using pdl format. C* +C* EXCPT 51 52 +C* SETOF 61 TO 78 +C* SETON L1 03 09 15 21 98 +C* SETON L1 03 01 TO 05 98 10 TO 15 +C* WBYTE LOKUP ARA EQ-09 USING X1 3.0 +C* WBYTE LOKUP ARA EQ-09 USING X 2.0 C* Sample program macro definition follows +C* MOVE1 MACRO .Move one value to three fields +C* MOVE &1 TO &2 +C* MOVE &1 TO &3 +C* MOVE &1 TO &4 +C* MEND C* Sample generation of above defined macro follows +C* MOVE1 FIELDA FIELDB FIELDC FIELDD 6 .Comment C* C* Redefine sample program macro +C* MOVE1 MACRO FIELD1 .Default value given for first field +C* MOVE &1 TO &2 &3 .Parm three is field length +C* MOVE &1 TO &4 &3 .Parm three is field length +C* MOVE &1 TO &5 &3 .PARM THREE IS FIELD LENGTH +C* MEND C* Generate new definition of sample program macro +C* MOVE1 , FIELD2 3.0 FIELD4 FIELD5 .Three moves C* C* Program macro sample using nesting of macros +C* NEST MACRO .Sample macro nesting +C* MOVE1 0 &1 3.0 FIELD2 FIELD3 FIELD4 +C* MOVE1 0 &1 , FIELD6 FIELD7 FIELD8 +C* MOVE1 ' ' &2 10 FIELDB FIELDC FIELDD +C* MEND C* Generate nested macro definition +C* NEST FIELDX FIELDY .Sample macro generation with nesting C* +C* SORTM ARA NME 10 .Sample library macro generation C* +C* ADD FIELD1 TO FIELD2 3.0 +C* ADD FIELD1 TO WTOTAL 5.0 P-98 +C* BITOF '0123' WBYTE 1 +C* BITON '4567' WTEST 1 +C* DEBUG FIELDA +C* DIV FIELD1 BY FIELD2 +C* DIV FIELD1 BY FIELD2 = WRESLT 5.2 +C* MVR WRMDR 5.0 P-97 +C* Z-ADD UDATE TO GDATE +C* EXSR SRDAYS +C* MHHZO 'A' TO WBYTE +C* MHLZO 'J' TO WBYTE +C* MLHZO 'S' TO WBYTE +C* MLLZO '0' TO WBYTE +C* MOVE FIELD2 TO FIELD1 5.0 +C* MOVEA 'STRING' TO ARA,5 +C* MOVEL WBYTE TO FIELDA +C* MULT FIELD1 BY FIELD2 P-98 +C* MULT FIELD1 BY FIELD2 = WRESLT +C* READ ISFILE2 +C* SUB 5 FROM FIELD2 +C* TESTB '0123' WBYTE OFF-98 +C* TESTZ WBYTE X-98 +C* TIME WTIME 6.0 +C* XFOOT SUM WTOTAL 5.0 +C* Z-ADD 5 TO FIELD2 +C* Z-SUB 1 FROM FIELD1 +C* ADD 1 TO WCOUNT 5.0 +C* FIELDA CHAIN ISFILE NF-98 +C* FIELDA COMP FIELDB EQ-98 +C* 'CHECK' DEBUG FIELDA +C* LEVEL USING 88 .Set work indicator to 88 +C* FIELD1 DIV FIELD2 = WRESLT +C* FIELDA KEY WREPLY 1 +C* WCOUNT MULT 5 = WTOTAL +C* FIELDB SET +C* FIELDA SETLL ISFILE2 +C* LOOP READ ISFILE2 EOF-98 +C* EXCPT 50 +C* IF FIELDA EQ 'A' +C* MOVE 'A' TO FIELDB +C* ELSE MOVE 'B' TO FIELDB +C* ENDIF +C* EXITIF FIELD1 EQ FIELD2 ANDDO EXSR TEST +C* .FUNCTION MUST FOLLOW EXITIF ... ANDDO +C* MOVE 'A' TO FIELD1 +C* ENDLOOP +C* LEVEL L1 .Set column 7-8 to l1 for following calcs +C* EXSR TEST +C* WCOUNT SUB 1 WTOTAL +C* LEVEL LR +C* MOVE FIELD6 TO FIELD6 6 +C* MOVE FIELD7 TO FIELD7 6 +C* COPY SRDAYS CSR TEST BEGSR +C* EXITSR CSR TEST99 ENDSR C/EJECT O* O* Section H - Precompiler screen output column generation. O* O* Note "+" in column 44 to identify column generation O* Field name GEN18 identifies group to be generated 18 times O* End position on GEN18 line specifies first output position. O* OWORKSTN E 52 O* K8 'EXAMPLE ' O 61 GEN18 1+ O NME B 20+ O NBR 31+'0 - - ' O AMT JB 41+ +O* COPY EXAMPL SELECT-O EX O* END OF SOURCE O/EJECT ** SAMPLE TABLE A B ** Precompiler Diagnostic Message Text When the precompiler detects an error, a diagnostic statement is generated that will cause an RPG II terminal error. The format of this diagnostic statement is shown in the following line- P D LC MOVE 'ERR# 888'#9999 The constant in factor 2 contains the error code, "888", and the result field (Undefined for RPG II) states the sequence number "9999" of the original precompiler source statement in error. The following table gives an explanation of each error code that may be generated by the precompiler. CODE EXPLANATION........ ... Codes 01 TO 99 Reserved for SYSTEM/3 "SOURCE" Users ... CODES 101 TO 199 - Pre-compiler phase one 101 "AND/OR" Must be the last word in a precompiler statement. 102 Maximum (15) number of words for one statement exceeded. 103 No ending quote within field size (10 characters) 104 RPS-STACK size exceeded. Precompiler program error. (POPRPG) 105 RPS-STACK index is zero or negative. Precompiler program error. 106 RPS-STACK size exceeded. Precompiler program error. (PSHRPG) 107 Invalid conditional word for precompiler verb. 108 Conditional word does not correspond to RPG II verb 109 Continuation statement error. 'AND/OR" connectors present but invalid for this precompiler statement. 110 Error, no statements generated for "COPY" function. 111 Program macro definition statement contains a value in position 6 that does not equal position 6 of the macro definition header. 112 Invalid placement for "macro" header statement. Previous program macro definition still in progress. "MEND" statement required but missing to terminate previous program macro definition. 113 End of source encountered before "mend" statement for program Macro definition. "MEND" statement required but missing to terminate program macro definition. 114 Continuation statement error. Previous statement contained and/or connectors but current statement is not a pre-compiler statement. 115 "ANDDO" Invalid for a continued (AND/OR) PDL statement. 116 Unidentified statement - precompiler format but no PDL identifier, RPG VERB, or macro name found. 117 "MEND" statement not preceded by "macro" header. 118 Unidentified special function verb. 119 120 More than one nested copy (macro) statement is invalid. 121 Macro not found in macro library. 122 Screen output (genxx field) greater than 24 lines ... Codes 201 TO 299 - Pre-compiler, Phase Two 201 "AND/OR" must be the last word in a precompiler statement. 202 Maximum (15) number of words for one statement exceeded. 203 No ending quote within field size (10 characters) 204 RPS-STACK size exceeded. Precompiler program error. (POPRPG) 205 RPS-STACK index is zero or negative. Precompiler program error. 206 RPS-STACK size exceeded. Precompiler program error. (PSHRPG) 207 Invalid conditional word for precompiler verb. 208 Conditional word does not correspond to RPG II verb. 209 Continuation statement error. 'AND/OR" connectors present but invalid for this precompiler statement. 210 NEST STACK index error at EOJ (Structure not closed) "ENDIF", "ENDSEL", "ENDLOOP", or "ENDDO" statement required but missing. 211 "SELECT CASE" header statement must be followed by a "CASE" statement. 212 Continuation statement error. Previous statement Contained and/or connectors but current statement is not a pre-compiler statement. 213 "ANDDO" invalid for a continued (AND/OR) PDL statement. 214 Unidentified precompiler statement 215 "IF" structure begins with other than "IF" statement. NEST INDEX error within "IF" structure. 216 Unidentified statement in an "IF" structure. 217 "IF" structure contains previously stated "ELSE" statement. 218 Invalid "CASE" statement continuation. And/or logic is valid only for "SELECT-CASE" structures that specify verb-format logic (no reserved words on "SELECT-CASE" header statement). 219 "SELECT-CASE" structure does not contain "SELECT-CASE" header statement. Nest index error within SELECT-CASE structure. 220 Unidentified statement in a "SELECT-CASE" structure. 221 "CASE" statement rejected. Multiple definition of HI,LO, or EQ case within HI/LO/EQ format "SELECT-CASE" structure. 222 "CASE DEFAULT" statement rejected. Default case previously specified within current "SELECT-CASE" structure. 223 "ENDSEL" statement rejected. Invalid or missing logic- format specification in "SELECT-CASE" header statement. 224 "ENDSEL" statement rejected. No "CASE" statements have been processed within current "SELECT-CASE" structure. No branch-table has been generated. 225 "CASE DEFAULT" Statement rejected. Default case is invalid for HI/LO/EQ format of "SELECT-CASE" structure. 226 "CASE" statement rejected. Only one value is allowed following the word "CASE" for the HI/LO/EQ format of the "SELECT-CASE" structure. 227 "CASE" statement rejected. HI/LO/EQ "SELECT-CASE" structure requires that all case statements specify a valid conditional word. See table of valid conditional words. 228 "CASE" statement rejected. No case values specifed. 229 Index error in "ENDSEL" verb format process. Program error. 230 "SELECT-CASE" statement requires 3 work indicators for HI/LO/EQ logic but no "LEVEL-USING" statement has been specified to identify additional work indicators. (Ex. Level using L9 L8 L7). 231 "SELECT-CASE" statement rejected. Invalid or missing logic- format specification in "SELECT-CASE" header statement. 232 "LOOP" structure does not contain "LOOP" header statement. Nest index error within "loop" structure. 233 Unidentified statement in a "LOOP" structure. 234 "LOOP" structure does not contain an "EXITIF" statement. 235 "DO" structure begins with other than "DO" statement. nest index error within "DO" structure. 236 unidentified statement in an "DO" structure. 237 "DO" statement rejected. The reserved words "WHILE" and "UNTIL" are mutually exclusive. It is invalid to specify both of these reserved words in a single "DO" statement. 238 "DO" statement rejected. The reserved words "TIMES" and "FROM" are mutually exclusive. It is invalid to specify both of these reserved words in a single "DO" statement. 239 "DO" statement rejected. "FROM/BY/TO" format specified but reserved word "TO" is missing. 240 "ENDDO" statement rejected. Invalid or missing logic- format specification in "DO" header statement or no "EXITIF" statements processed within structure. 241 Index error IN "DO-UNTIL" verb format process. Program error. 242 reserved word "ANDDO" invalid for this statement. 243 Special function verb other than "LEVEL" is invalid for precompiler phase 2. Check for phase 1 error. 244 "LEVEL" statement with "USING" parameter rejected. Duplicate work indicators have resulted. Specify all 3 work indicators following "USING" to avoid unintentional duplication. 245 Invalid or missing condition for "READ" verb. The conditional word "EOF" or "NEOF" is required. 246 Unable to process this statement as a precompiler verb. No result indicator reserved words are present. 247 "FIRST-CYCLE/INDICATOR/BIT" logic may not be present in a continuation statement. (AND/OR) 248 "FIRST-INDICATOR" logic statement may not be continued by AND/OR continuation lines. 249 Invalid "FIRST" logic statement. The word following "FIRST" must be either the word "CYCLE", or a bit number (1-7), or a valid RPG indicator. 250 Invalid or missing rpg verb. Unable to generate rpg statement for this conditional expression. 251 AN invalid combination of verb types has been specified in a continuation (AND/OR) statement sequence. indicator (EX. 01-ON) and field (Ex. A EQ B) verbs may not be combined by and/or logic. 252 Invalid combination of verbs: Verbs that set an indicator on when "TRUE" (EX. A EQ B) cannot be combined (AND/OR) with verbs that set an indicator off when "TRUE" (Ex. Key chain file f (found) use a separate structure or statement to implement this logic. 253 TAG-STACK index error. Current structure does not agree with current tag-label prefix. (GETTAG) 254 TAG-STACK index is zero or greater than top of stack. (GETTAG) 255 CASE-STACK index is zero. Program error. 256 CASE-STACK size exceeded. Reduce nesting by using subroutines or separate pdl structures (ENDIF/IF FOR ELSEIF). (CASE-STACK is reset when all pdl structures are closed). 257 TAG-STACK index error. Current structure does not agree with current tag-label prefix. (PUTTAG) 258 TAG-LABEL stack size exceeded. Reduce nesting by using subroutines or separate pdl structures (ENDIF/IF FOR ELSEIF). (TAG-STACK is reset when all PDL structures are closed). 259 TAG-STACK index is zero. Program error. 260 NEST-STACK size exceeded. Reduce nesting by using subroutines or separate pdl structures (ENDIF/IF FOR ELSEIF). (NEST-STACK is reset when all PDL structures are closed). 261 RPG-STACK size exceeded. Reduce stack requirements by using subroutines or separate pdl structures or by reducing the number of continuation lines in the current pdl structure. (Rpg-stack is reset when all pdl structures are closed). 262 RPG-STACK index is zero or negative. Precompiler program error 263 NEST INDEX error at end of structure. Too many "END--" statements. 264 NEST STACK index error at endsr (structure not closed). "ENDIF", "ENDSEL", "ENDLOOP", OR "ENDDO" statement required but missing. 265 Continuation statement error. Previous statement contained and/or connectors but current statement has not generated any logic (no indicator has been set). ... End of error codes