Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
blog:iseries:rpg [2020/03/06 12:27] 127.0.0.1 external edit |
blog:iseries:rpg [2020/03/07 04:37] (current) tom [Strings] |
||
---|---|---|---|
Line 1: | Line 1: | ||
[[me:as400:rpg_free]] | [[me:as400:rpg_free]] | ||
- | |||
- | <code> | ||
- | *...1....+....2....+....3....+....4....+....5....+....6....+....7... | ||
- | IFilename++SqNORiPos1+NCCPos2+NCCPos3+NCC................................ | ||
- | I........................Fmt+SPFrom+To+++DcField+++++++++L1M1FrPlMnZr.... | ||
- | DName+++++++++++ETDsFrom+++To/L+++IDc.Keywords+++++++++++++++++++++++++++++ | ||
- | CL0N01Factor1+++++++Opcode(E)+Factor2+++++++Result++++++++Len++D+HiLoEq.. | ||
- | OFilename++DF..N01N02N03Excnam++++B++A++Sb+Sa+........................... | ||
- | O..............N01N02N03Field+++++++++YB.End++PConstant/editword/DTformat | ||
- | </code> | ||
- | |||
- | <code rpgfree> | ||
- | * Testing comments | ||
- | * Testing comments | ||
- | %SUBST(A(3:4))= ’****’; | ||
- | %CHAR(date : *iso) | ||
- | |||
- | /* I........................Fmt+SPFrom+To+++DcField+++++++++L1M1FrPlMnZr.... | ||
- | DName+++++++++++ETDsFrom+++To/L+++IDc.Keywords+++++++++++++++++++++++++++++ | ||
- | CL0N01Factor1+++++++Opcode(E)+Factor2+++++++Result++++++++Len++D+HiLoEq.. | ||
- | OFilename++DF..N01N02N03Excnam++++B++A++Sb+Sa+........................... | ||
- | O..............N01N02N03Field+++++++++YB.End++PConstant/editword/DTformat */ | ||
- | </code> | ||
**Misc tips/reminders** | **Misc tips/reminders** | ||
Line 58: | Line 35: | ||
===== BIFs ===== | ===== BIFs ===== | ||
- | ; %Abs | + | %Abs |
: absolute value | : absolute value | ||
- | ; %Char | + | %Char |
: converts to character<code rpgfree>%CHAR(date : *iso)</code> | : converts to character<code rpgfree>%CHAR(date : *iso)</code> | ||
- | ; %Check(look_for: string_to_search) | + | %Check(look_for: string_to_search) |
: first position in string_to_search that is not a value in look_for | : first position in string_to_search that is not a value in look_for | ||
- | ; %Date(optional_date: optional_date_format) | + | %Date(optional_date: optional_date_format) |
: if no date supplied, then get current date | : if no date supplied, then get current date | ||
- | ; %Days | + | %Days |
: number of days as a duration | : number of days as a duration | ||
- | ; %Dec | + | %Dec |
: convert to packed number | : convert to packed number | ||
- | ; %Dech | + | %Dech |
: convert to packed number (half-adjusted) | : convert to packed number (half-adjusted) | ||
- | ; %DecPos | + | %DecPos |
: # of decimal digits | : # of decimal digits | ||
- | ; %Diff | + | %Diff |
: diff between 2 dates/times | : diff between 2 dates/times | ||
- | ; %Div | + | %Div |
: divide 2 numbers<code rpgfree>DIV = %DIV(A:B); (divide A by B)</code> | : divide 2 numbers<code rpgfree>DIV = %DIV(A:B); (divide A by B)</code> | ||
- | ; %Editc(Number: 'X': *CURSYM) | + | %Editc(Number: 'X': *CURSYM) |
: edit code (numeric) | : edit code (numeric) | ||
- | <code rpgfree> * Common codes (the X, above, or used in O specs) | + | * Common codes (the X, above, or used in O specs) |
* 1-4 have no negative sign | * 1-4 have no negative sign | ||
* 5-9 are user-defined @ system level | * 5-9 are user-defined @ system level | ||
Line 86: | Line 63: | ||
* J is most common (commas, dec separator, - for neg, shows zeros) | * J is most common (commas, dec separator, - for neg, shows zeros) | ||
* K (commas, dec separator, - for neg, zeros suppressed) | * K (commas, dec separator, - for neg, zeros suppressed) | ||
- | * Y - for dates</code> | + | * Y - for dates |
|Edit Code Description|No Sign|CR Sign|-Sign (R)|-Sign (L)| | |Edit Code Description|No Sign|CR Sign|-Sign (R)|-Sign (L)| | ||
|Commas and zero balances|1|A|J|N| | |Commas and zero balances|1|A|J|N| | ||
Line 97: | Line 75: | ||
|Date edit|Y| | |Date edit|Y| | ||
|Suppress leading zeros|Z| | |Suppress leading zeros|Z| | ||
- | ; %Editw | + | |
- | : edit word<code rpgfree> * first zero ends zero-suppression (leading zeros after that position are printed) | + | %Editw |
+ | : edit word | ||
+ | * first zero ends zero-suppression (leading zeros after that position are printed) | ||
* first asterisk also ends zero-suppression, but causes leading asterisks in the ouput | * first asterisk also ends zero-suppression, but causes leading asterisks in the ouput | ||
- | * 'b*bbbbbb.bb' (each b is a blank/space character) applied to 12345 prints ***123.45 | + | * <nowiki>'b*bbbbbb.bb' (each b is a blank/space character) applied to 12345 prints ***123.45</nowiki> |
* a currency symbol followed by a zero floats | * a currency symbol followed by a zero floats | ||
* 'bb,bbb,b$0.bb' applied to 12 prints $.12 | * 'bb,bbb,b$0.bb' applied to 12 prints $.12 | ||
Line 108: | Line 88: | ||
* any other character prints that exact character | * any other character prints that exact character | ||
* 'bb/bb/bb' aplied to 12345 prints b1/23/45 | * 'bb/bb/bb' aplied to 12345 prints b1/23/45 | ||
- | * '0bb/bb/bb' aplied to 12345 prints b01/23/45</code> | + | * '0bb/bb/bb' aplied to 12345 prints b01/23/45 |
- | ; %Elem | + | %Elem |
: # of elements or occurrences | : # of elements or occurrences | ||
- | ; %EOF(filename) | + | %EOF(filename) |
: "1" if EOF | : "1" if EOF | ||
- | ; %Equal | + | %Equal |
: "1" if SETLL or LOOKUP found an exact match | : "1" if SETLL or LOOKUP found an exact match | ||
- | ; %Error | + | %Error |
: "1" if op code with "E" extender hit an error | : "1" if op code with "E" extender hit an error | ||
- | ; %Fields | + | %Fields |
: update record %fields(salary:status); | : update record %fields(salary:status); | ||
- | ; %Float | + | %Float |
: converts to float | : converts to float | ||
- | ; %Found(optional_filename) | + | %Found(optional_filename) |
: "1" if found (CHAIN, DELETE, SETGT, SETLL), an element (LOOKUP), or a match (CHECK, CHECKR, SCAN) | : "1" if found (CHAIN, DELETE, SETGT, SETLL), an element (LOOKUP), or a match (CHECK, CHECKR, SCAN) | ||
- | ; %Int | + | %Int |
- | ; %Inth | + | %Inth |
: half adjusted integet | : half adjusted integet | ||
- | ; %Len | + | %Len |
- | ; %Lookupxx(argument: array{:start index {:number of elements}} | + | %Lookupxx(argument: array{:start index {:number of elements}} |
: array index of the matching element | : array index of the matching element | ||
- | ; %Occur(DS) | + | %Occur(DS) |
: active occurrence # of the DS | : active occurrence # of the DS | ||
- | ; %Open(filename) | + | %Open(filename) |
: "1" if open | : "1" if open | ||
- | ; %Parms | + | %Parms |
: # of parms passed into pgm | : # of parms passed into pgm | ||
- | ; %Rem | + | %Rem |
: remainder<code rpgfree> REM = %REM(A:B);</code> | : remainder<code rpgfree> REM = %REM(A:B);</code> | ||
- | ; %Replace(string: into_string: optional_start: optional_length) | + | %Replace(string: into_string: optional_start: optional_length) |
- | ; %Scan(look_for: look_in: optional_start) | + | %Scan(look_for: look_in: optional_start) |
: 1st position of look_for within look_in | : 1st position of look_for within look_in | ||
- | ; %Size | + | %Size |
- | : size of a variable or text string (not length)<code rpgfree> DIM(%SIZE(OTHER_FIELD)) | + | : size of a variable or text string (not length) |
- | Use %size and %substr to extract 3 concatenated fields WITHOUT hard-coding the field sizes | + | <code rpgfree> DIM(%SIZE(OTHER_FIELD)) |
+ | // Use %size and %substr to extract 3 concatenated fields WITHOUT hard-coding the field sizes | ||
eval #cono = %subst($$id:1:%size(#cono)) | eval #cono = %subst($$id:1:%size(#cono)) | ||
eval #cusn = %subst($$id:%size(#cono)+1:%size(#cusn)) | eval #cusn = %subst($$id:%size(#cono)+1:%size(#cusn)) | ||
eval #dseq = %subst($$id:%size(#cono)+%size(#cusn)+1:%size(#dseq))</code> | eval #dseq = %subst($$id:%size(#cono)+%size(#cusn)+1:%size(#dseq))</code> | ||
- | ; %Subdt(date: unit) | + | %Subdt(date: unit) |
- | : "date substring" - portion of a date<code rpgfree> | + | : "date substring" - portion of a date |
+ | <code rpgfree> | ||
%SUBDT(value:*MSECONDS|*SECONDS|*MINUTES|*HOURS|*DAYS|*MONTHS|*YEARS) | %SUBDT(value:*MSECONDS|*SECONDS|*MINUTES|*HOURS|*DAYS|*MONTHS|*YEARS) | ||
%SUBDT(value:*MS|*S|*MN|*H|*D|*M|*Y)</code> | %SUBDT(value:*MS|*S|*MN|*H|*D|*M|*Y)</code> | ||
- | ; %Subst | + | %Subst |
- | : substring(string:start:length)<code rpgfree> // After the EVAL the original value of A contains ’ab****ghijklmno’ | + | : substring(string:start:length) |
+ | <code rpgfree> // After the EVAL the original value of A contains ’ab****ghijklmno’ | ||
%SUBST(A(3:4))= ’****’;</code> | %SUBST(A(3:4))= ’****’;</code> | ||
- | ; %Time | + | %Time |
- | ; %Timestamp | + | %Timestamp |
- | ; %TLookupxx(argument: search table {: alternate table} | + | %TLookupxx(argument: search table {: alternate table} |
: "1" if match, "0" otherwise | : "1" if match, "0" otherwise | ||
- | ; %Trim | + | %Trim |
- | ; %Triml | + | %Triml |
- | ; %Trimr | + | %Trimr |
- | ; %Uns | + | %Uns |
: unsigned number | : unsigned number | ||
- | ; %XFoot(array) | + | %XFoot(array) |
: sum of the elements | : sum of the elements | ||
- | ; %Xlate(Lower:Upper:String) | + | %Xlate(Lower:Upper:String) |
Line 170: | Line 153: | ||
===== C-Specs ===== | ===== C-Specs ===== | ||
- | ; CAT(P) | + | CAT(P) |
: optional (P) = pad with blanks (on right side) | : optional (P) = pad with blanks (on right side) | ||
: CAT FLD1:2 FLD2 - put 2 blanks between FLD1 and FLD2 | : CAT FLD1:2 FLD2 - put 2 blanks between FLD1 and FLD2 | ||
- | ; CHECK | + | CHECK |
- | ; CHECKR | + | CHECKR |
- | ; CLEAR | + | CLEAR |
: Only initializes Output or Both fields - NOT Input Only fields | : Only initializes Output or Both fields - NOT Input Only fields | ||
- | ; Eval | + | Eval |
: "normal" eval - same as MOVEL | : "normal" eval - same as MOVEL | ||
- | ; Eval(R) | + | Eval(R) |
: forces intermediate numbers to have the same precision as the result | : forces intermediate numbers to have the same precision as the result | ||
- | ; Evalr | + | Evalr |
: eval with right adjust - same as MOVE command | : eval with right adjust - same as MOVE command | ||
- | ; FEOD | + | FEOD |
: Force End of Data (forces an EOF condition) | : Force End of Data (forces an EOF condition) | ||
: does not close files | : does not close files | ||
- | ; FOR | + | FOR |
: for i = %len(field) downto 1; | : for i = %len(field) downto 1; | ||
: for i = 1 to %len(field); | : for i = 1 to %len(field); | ||
: for i = 1 by 2 to %len(field); (same as STEP 2 in VBA) | : for i = 1 by 2 to %len(field); (same as STEP 2 in VBA) | ||
- | ; GOTO | + | GOTO |
: jump-to points are defined with TAG opcode | : jump-to points are defined with TAG opcode | ||
- | ; Max() | + | Max() |
- | ; Min() | + | Min() |
- | ; SCAN | + | SCAN |
- | ; SUBST | + | SUBST |
- | ; TIME | + | TIME |
: if the result file is 6,0, then it returns just HHMMSS | : if the result file is 6,0, then it returns just HHMMSS | ||
: if the result file is 12,0, then it returns hhmmssMMDDYY | : if the result file is 12,0, then it returns hhmmssMMDDYY | ||
- | ; TRIM | + | TRIM |
- | ; TRIML | + | TRIML |
- | ; TRIMR | + | TRIMR |
- | ; XFOOT | + | XFOOT |
: Adds all elements of an array into a result field | : Adds all elements of an array into a result field | ||
- | ; Continuation Lines for C-Specs | + | Continuation Lines for C-Specs |
: - each pair below has the same meaning | : - each pair below has the same meaning | ||
: - in the last example, you could use (-) instead of (+), but then the next line must start in position 1 of the field<code rpgfree> | : - in the last example, you could use (-) instead of (+), but then the next line must start in position 1 of the field<code rpgfree> | ||
Line 217: | Line 200: | ||
C c'</code> | C c'</code> | ||
- | ; Continuation for field names use elipses<code rpgfree>C eval MyLongF... | + | Continuation for field names use elipses<code rpgfree>C eval MyLongF... |
C ieldName = A + B</code> | C ieldName = A + B</code> | ||
Line 238: | Line 221: | ||
* LR = indicator seton if called pgm seton LR | * LR = indicator seton if called pgm seton LR | ||
- | ; CALLB(D/E) | + | CALLB(D/E) |
: used to call bound procedures | : used to call bound procedures | ||
: (D) include operational descriptors | : (D) include operational descriptors | ||
: (E) enables exception handling | : (E) enables exception handling | ||
- | ; CALLP(E M/R) | + | CALLP(E M/R) |
: used to call prototyped procedures or programs | : used to call prototyped procedures or programs | ||
Line 248: | Line 231: | ||
===== CHAIN ===== | ===== CHAIN ===== | ||
- | ; CHAIN(EN) | + | CHAIN(EN) |
: (E) enables exception handling | : (E) enables exception handling | ||
: (N) do not lock the record | : (N) do not lock the record | ||
Line 261: | Line 244: | ||
<code rpgfree> | <code rpgfree> | ||
DName+++++++++++ETDsFrom+++To/L+++IDc.Keywords+++++++++++++++++++++++++ | DName+++++++++++ETDsFrom+++To/L+++IDc.Keywords+++++++++++++++++++++++++ | ||
- | D custRecKeys ds likerec(custRec : *key)</code> | + | D custRecKeys ds likerec(custRec : *key)</code> |
<code rpgfree>/free | <code rpgfree>/free | ||
Line 275: | Line 258: | ||
chain (’abc’ : ’AB’) custRec custRecDs;</code> | chain (’abc’ : ’AB’) custRec custRecDs;</code> | ||
- | ------------------------------------------------------------------------------- | + | ---- |
===== CHECK & CHECKR ===== | ===== CHECK & CHECKR ===== | ||
Line 298: | Line 281: | ||
===== CLEAR vs. RESET ===== | ===== CLEAR vs. RESET ===== | ||
- | ; CLEAR | + | CLEAR |
: Clears all fields (resets them to *ZERO, *BLANK or *OFF) | : Clears all fields (resets them to *ZERO, *BLANK or *OFF) | ||
- | ; RESET | + | RESET |
: Resets all fields to the value they had after the *INIT operation (which includes the *INZSR routine, and all D.S. inits ('I' in column 8 of a D.S. subfield.) | : Resets all fields to the value they had after the *INIT operation (which includes the *INZSR routine, and all D.S. inits ('I' in column 8 of a D.S. subfield.) | ||
Line 698: | Line 681: | ||
* If *DTAARA RPGHSPEC exists in the library list, it over-rides the one in QRPG. | * If *DTAARA RPGHSPEC exists in the library list, it over-rides the one in QRPG. | ||
- | ; ACTGRP(*NEW | *CALLER | 'activation-group-name') | + | ACTGRP(*NEW | *CALLER | 'activation-group-name') |
- | ; ALWNULL(*NO | *INPUTONLY | *USRCTL) | + | ALWNULL(*NO | *INPUTONLY | *USRCTL) |
- | ; AUT(*LIBRCRTAUT | *ALL | *CHANGE | *USE | *EXCLUDE | 'authorization-list-name') | + | AUT(*LIBRCRTAUT | *ALL | *CHANGE | *USE | *EXCLUDE | 'authorization-list-name') |
- | ; BNDDIR('binding-directory-name' {:'binding-directory-name'...}) | + | BNDDIR('binding-directory-name' {:'binding-directory-name'...}) |
- | ; CURSYM('sym') | + | CURSYM('sym') |
- | ; DATEDIT(fmt{separator}) | + | DATEDIT(fmt{separator}) |
: (fmt) can be *DMY, *MDY, or *YMD | : (fmt) can be *DMY, *MDY, or *YMD | ||
- | ; DATFMT(fmt{separator}) | + | DATFMT(fmt{separator}) |
: ISO is the default | : ISO is the default | ||
- | ; DEBUG{(*NO | *YES)} | + | DEBUG{(*NO | *YES)} |
: specifies whether DUMP operations are performed | : specifies whether DUMP operations are performed | ||
- | ; DFTACTGRP(*YES | *NO) | + | DFTACTGRP(*YES | *NO) |
: see ACTIVATION GROUPS, below | : see ACTIVATION GROUPS, below | ||
- | ; EXPROPTS(*MAXDIGITS | *RESDECPOS) | + | EXPROPTS(*MAXDIGITS | *RESDECPOS) |
: same as M and R opcode extenders | : same as M and R opcode extenders | ||
: controls precision of intermediate calcs | : controls precision of intermediate calcs | ||
- | ; FORMSALIGN{(*NO | *YES)} | + | FORMSALIGN{(*NO | *YES)} |
: if *YES, the first line of output files with 1P indicator can be printed repeatedly, allowing you to align the printer | : if *YES, the first line of output files with 1P indicator can be printed repeatedly, allowing you to align the printer | ||
- | ; GENLVL(number) | + | GENLVL(number) |
: for compile errors | : for compile errors | ||
- | ; NOMAIN | + | NOMAIN |
: for modules | : for modules | ||
- | ; OPTION(*{NO}XREF *{NO}SECLVL *{NO}SHOWCPY *{NO}EXPDDS *{NO}EXT *{NO}SHOWSKP) *{NO}SRCSTMT) *{NO}DEBUGIO) | + | OPTION(*{NO}XREF *{NO}SECLVL *{NO}SHOWCPY *{NO}EXPDDS *{NO}EXT *{NO}SHOWSKP) *{NO}SRCSTMT) *{NO}DEBUGIO) |
: SECLVL = second-level message text | : SECLVL = second-level message text | ||
: SHOWCPY expands /COPY directives | : SHOWCPY expands /COPY directives | ||
Line 728: | Line 711: | ||
: NOSRCSTMT indicates that line numbers from /COPY directives are assigned sequentially | : NOSRCSTMT indicates that line numbers from /COPY directives are assigned sequentially | ||
: DEBUGIO generates breakpoints for all input and output specifications | : DEBUGIO generates breakpoints for all input and output specifications | ||
- | ; PRFDTA(*NOCOL | *COL) - for profiling (not performance) data | + | PRFDTA(*NOCOL | *COL) - for profiling (not performance) data |
- | ; TRUNCNBR(*YES | *NO) | + | TRUNCNBR(*YES | *NO) |
- | ; USRPRF(*USER | *OWNER) | + | USRPRF(*USER | *OWNER) |
: *OWNER = adopted authority | : *OWNER = adopted authority | ||
Line 751: | Line 734: | ||
==== ACTIVATION GROUPS ==== | ==== ACTIVATION GROUPS ==== | ||
- | * QILE is default activation group for modules | + | * QILE is default activation group for modules |
- | * QSRVPGM is default activation group for service pgms | + | * QSRVPGM is default activation group for service pgms |
- | * default ACTGRPs limit the ILE funcions | + | * default ACTGRPs limit the ILE funcions |
- | * can't bind objects | + | * can't bind objects |
- | * pgm CALLs can only call other pgms, not procedures | + | * pgm CALLs can only call other pgms, not procedures |
- | * allows partitioning of job resources (file overrides, committment definitions, and open files) | + | * allows partitioning of job resources (file overrides, committment definitions, and open files) |
- | * can control job activation and deactivation, improving performance | + | * can control job activation and deactivation, improving performance |
- | * allows use of shared ODPs | + | * allows use of shared ODPs |
- | * if using mixed ILE and non-ILE, use default activation group | + | * if using mixed ILE and non-ILE, use default activation group |
- | * when an ILE pgm ends, the system doesn't always remove the storage for that pgm activation from the job | + | * when an ILE pgm ends, the system doesn't always remove the storage for that pgm activation from the job |
- | * manual use of RCLACTGRP can improve performance | + | * manual use of RCLACTGRP can improve performance |
==== BINDING DIRECTORIES ==== | ==== BINDING DIRECTORIES ==== | ||
Line 965: | Line 948: | ||
===== Literals ===== | ===== Literals ===== | ||
<code rpgfree> | <code rpgfree> | ||
- | H DATFMT(*ISO) | + | H DATFMT(*ISO) |
- | * Examples of literals used to initialize fields | + | * Examples of literals used to initialize fields |
- | DName+++++++++++ETDsFrom+++To/L+++IDc.Keywords+++++++++++++++++++++++++++++ | + | DName+++++++++++ETDsFrom+++To/L+++IDc.Keywords+++++++++++++++++++++++++++++ |
- | D DateField S D INZ(D'1988-09-03') | + | D DateField S D INZ(D'1988-09-03') |
- | D NumField S 5P 1 INZ(5.2) | + | D NumField S 5P 1 INZ(5.2) |
- | D CharField S 10A INZ('abcdefghij') | + | D CharField S 10A INZ('abcdefghij') |
- | D UCS2Field S 2C INZ(U'00610062') | + | D UCS2Field S 2C INZ(U'00610062') |
- | * Even though the date field is defined with a 2-digit year, the | + | * Even though the date field is defined with a 2-digit year, the |
- | * initialization value must be defined with a 4-digit year, since | + | * initialization value must be defined with a 4-digit year, since |
- | * all literals must be specified in date format specified | + | * all literals must be specified in date format specified |
- | * on the control specification. | + | * on the control specification. |
- | D YmdDate S D INZ(D'2001-01-13') | + | D YmdDate S D INZ(D'2001-01-13') |
- | D DATFMT(*YMD) | + | D DATFMT(*YMD) |
- | * Examples of literals used to define named constants | + | * Examples of literals used to define named constants |
- | D DateConst C CONST(D'1988-09-03') | + | D DateConst C CONST(D'1988-09-03') |
- | D NumConst C CONST(5.2) | + | D NumConst C CONST(5.2) |
- | D CharConst C CONST('abcdefghij') | + | D CharConst C CONST('abcdefghij') |
- | * Note that the CONST keyword is not required. | + | * Note that the CONST keyword is not required. |
- | D Upper C 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' | + | D Upper C 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' |
- | * Note that the literal may be continued on the next line | + | * Note that the literal may be continued on the next line |
- | D Lower C 'abcdefghijklmn- | + | D Lower C 'abcdefghijklmn- |
- | D opqrstuvwxyz'</code> | + | D opqrstuvwxyz'</code> |
==== float literals ==== | ==== float literals ==== | ||
Line 1064: | Line 1047: | ||
===== Monitor (for errors) ===== | ===== Monitor (for errors) ===== | ||
<code rpgfree> | <code rpgfree> | ||
- | c monitor * start monitor | + | c monitor * start monitor |
- | c eval ivinue = ivinue + movc95 * eval equation | + | c eval ivinue = ivinue + movc95 * eval equation |
- | c on-error 0103 * field too small | + | c on-error 0103 * field too small |
- | c eval ivinue = *hival * reset | + | c eval ivinue = *hival * reset |
- | c endmon * end monitor | + | c endmon * end monitor |
</code> | </code> | ||
------------------------------------------------------------------------------- | ------------------------------------------------------------------------------- | ||
Line 1147: | Line 1130: | ||
CLOSE...</code> | CLOSE...</code> | ||
- | ; alias | + | alias |
: an alternate name for a table, view, or member | : an alternate name for a table, view, or member | ||
<code sql>CREATE ALIAS MYLIB.MYMBR2_ALIAS FOR MYLIB.MYFILE(MBR2)</code> | <code sql>CREATE ALIAS MYLIB.MYMBR2_ALIAS FOR MYLIB.MYFILE(MBR2)</code> | ||
- | ; Alter Table | + | Alter Table |
: add/drop/alter columns | : add/drop/alter columns | ||
: add/drop constraints | : add/drop constraints | ||
- | ; Comment On | + | Comment On |
: adds long text (2000 char max for V5R3) to object | : adds long text (2000 char max for V5R3) to object | ||
- | ; Constraint | + | Constraint |
: database rules (unique, referential, or check) | : database rules (unique, referential, or check) | ||
- | ; Create commands create 2 names - an SQL name (128 char max) and a system name (10 char max) | + | Create commands create 2 names - an SQL name (128 char max) and a system name (10 char max) |
- | ; Create Table (PF) | + | Create Table (PF) |
- | %%Create Table xxx As Select...%% | + | <code sql>Create Table xxx As Select...</code> |
: creates a table using a subset of field from an existing table | : creates a table using a subset of field from an existing table | ||
- | %%Create Table xxx Like MyTable...%% | + | <code sql>Create Table xxx Like MyTable...</code> |
: all fields in referenced table used in created table | : all fields in referenced table used in created table | ||
- | ; Create View | + | Create View |
: (LF - unkeyed) | : (LF - unkeyed) | ||
- | ; Create Index | + | Create Index |
: (LF - keyed) | : (LF - keyed) | ||
- | ; data dictionary | + | data dictionary |
: a set of tables containing object definitions | : a set of tables containing object definitions | ||
- | ; DECLARE cname CURSOR | + | DECLARE cname CURSOR |
: the default "declare cursor" only allows 1 retrieval per record, and there's no navigating backwards | : the default "declare cursor" only allows 1 retrieval per record, and there's no navigating backwards | ||
- | ; DECLARE cname SCROLL CURSOR | + | DECLARE cname SCROLL CURSOR |
: to enable fetch prior or fetch first, use a scrollable cursor | : to enable fetch prior or fetch first, use a scrollable cursor | ||
- | ; Drop | + | Drop |
: deletes database objects | : deletes database objects | ||
- | ; Fetch Next From ... For 10 Rows Into :DS | + | Fetch Next From ... For 10 Rows Into :DS |
- | ; Functions (UDFs) | + | Functions (UDFs) |
: execute like BIFs (meaning, inline within code) | : execute like BIFs (meaning, inline within code) | ||
- | ; Index | + | Index |
: keyed LF | : keyed LF | ||
- | ; Insert Into MyFile 10 Rows Values :DS | + | Insert Into MyFile 10 Rows Values :DS |
- | ; Label On | + | Label On |
: adds text (50 chars) and/or column heading (60 chars) | : adds text (50 chars) and/or column heading (60 chars) | ||
- | ; Rename | + | Rename |
: for objects, including system name portions of object names | : for objects, including system name portions of object names | ||
: Rename Table Customer_Master To SYSTEM NAME CustMast | : Rename Table Customer_Master To SYSTEM NAME CustMast | ||
- | ; schema | + | schema |
: consists of a library, a journal, a journal receiver, a catalog, and optionally, a data dictionary | : consists of a library, a journal, a journal receiver, a catalog, and optionally, a data dictionary | ||
- | ; sequence | + | sequence |
: a data area object that provides a quick and easy way of generating unique numbers | : a data area object that provides a quick and easy way of generating unique numbers | ||
- | ; Stored Procedure | + | Stored Procedure |
: executed via CALL statement | : executed via CALL statement | ||
- | ; System Name | + | System Name |
: Create commands create 2 names - an SQL name (128 char max) and a system name (10 char max) | : Create commands create 2 names - an SQL name (128 char max) and a system name (10 char max) | ||
: see below for SQL over system table | : see below for SQL over system table | ||
: may want to rename them | : may want to rename them | ||
- | ; trigger | + | trigger |
: a set of actions that are run automatically whenever a specified event occurs to a specified base table | : a set of actions that are run automatically whenever a specified event occurs to a specified base table | ||
- | ; UDT | + | UDT |
- | <code sql>CREATE DISTINCT TYPE US_DOLLAR AS DECIMAL (9,2)</code> | + | <code sql>CREATE DISTINCT TYPE US_DOLLAR AS DECIMAL (9,2)</code> |
: can then create tables with field types of US_DOLLAR (or string, integer, etc.) | : can then create tables with field types of US_DOLLAR (or string, integer, etc.) | ||
- | ; view | + | view |
: can point to multiple tables, can have a subset of columns | : can point to multiple tables, can have a subset of columns | ||
------------ | ------------ | ||
Line 1391: | Line 1374: | ||
| TRIMR | %TRIMR | | | TRIMR | %TRIMR | | ||
- | ------------------------------------------------------------------------------- | ||
===== Strip Leading Zeros ===== | ===== Strip Leading Zeros ===== | ||
Line 1410: | Line 1392: | ||
===== Subfiles ===== | ===== Subfiles ===== | ||
- | ; CSRLOC(ROW COLUMN) | + | CSRLOC(ROW COLUMN) |
: where to make the cursor appear | : where to make the cursor appear | ||
- | ; Error Handling | + | Error Handling |
: turn on indicator for DSPATR(RI PC) for fields with errors | : turn on indicator for DSPATR(RI PC) for fields with errors | ||
- | ; Page Size | + | Page Size |
: if page size = SFL size, then pgm must handle PAGEUP and PAGEDN | : if page size = SFL size, then pgm must handle PAGEUP and PAGEDN | ||
: also, if the last record exactly fills the page, the pgm shows More, even though there are no more | : also, if the last record exactly fills the page, the pgm shows More, even though there are no more | ||
: read ahead to see if we're @ EOF, then readp, then show More or Bottom | : read ahead to see if we're @ EOF, then readp, then show More or Bottom | ||
- | ; ROLLDOWN (same as PAGEUP) - use same indicator as SFLDSP | + | ROLLDOWN (same as PAGEUP) - use same indicator as SFLDSP |
- | ; ROLLUP (same as PAGEDOWN) - use same indicator as SFLDSP | + | ROLLUP (same as PAGEDOWN) - use same indicator as SFLDSP |
- | ; RTNCSRLOC(&CSRRCD &CSRFLD &CSRFLP) | + | RTNCSRLOC(&CSRRCD &CSRFLD &CSRFLP) |
: 2 formats - this format retrieves record name, field name, and option al cursor location within the field | : 2 formats - this format retrieves record name, field name, and option al cursor location within the field | ||
- | ; RTNCSRLOC(*WINDOW &CSRROW &CSRCOL &WDWROW &WDWCOL) | + | RTNCSRLOC(*WINDOW &CSRROW &CSRCOL &WDWROW &WDWCOL) |
: 2 formats - this format retrieves the cursor row and column | : 2 formats - this format retrieves the cursor row and column | ||
- | ; SFLCLR | + | SFLCLR |
: clear the subfile - duh! | : clear the subfile - duh! | ||
: Use the same indicator as SFLDSPCTL, except SFLDSP uses "Not on" | : Use the same indicator as SFLDSPCTL, except SFLDSP uses "Not on" | ||
- | ; SFLDSP | + | SFLDSP |
: Only show/display the SFL when this is on | : Only show/display the SFL when this is on | ||
- | ; SFLDSPCTL | + | SFLDSPCTL |
: Only show/display the control record when this is on | : Only show/display the control record when this is on | ||
- | ; SFLNXTCHG | + | SFLNXTCHG |
: forces record to appear changed | : forces record to appear changed | ||
: user presses Enter, validate screen, errors found, turn on SFLNXTCHG and error indicator, write back to screen | : user presses Enter, validate screen, errors found, turn on SFLNXTCHG and error indicator, write back to screen | ||
Line 1445: | Line 1427: | ||
The test operations are: | The test operations are: | ||
- | ; TEST | + | TEST |
: Test Date/Time/Timestamp | : Test Date/Time/Timestamp | ||
- | ; TESTB | + | TESTB |
: Test Bit | : Test Bit | ||
- | ; TESTN | + | TESTN |
: Test Numeric | : Test Numeric | ||
- | ; TESTZ | + | TESTZ |
: Test Zone | : Test Zone | ||
Line 1464: | Line 1446: | ||
Translate all lower case characters to upper case (LWR & UPR need to be constants or tables) | Translate all lower case characters to upper case (LWR & UPR need to be constants or tables) | ||
<code rpgfree>C LWR:UPR XLATE FIELD FIELD</code> | <code rpgfree>C LWR:UPR XLATE FIELD FIELD</code> | ||
+ | |||
+ | Old-School Column Markers | ||
+ | <code> | ||
+ | *...1....+....2....+....3....+....4....+....5....+....6....+....7... | ||
+ | IFilename++SqNORiPos1+NCCPos2+NCCPos3+NCC................................ | ||
+ | I........................Fmt+SPFrom+To+++DcField+++++++++L1M1FrPlMnZr.... | ||
+ | DName+++++++++++ETDsFrom+++To/L+++IDc.Keywords+++++++++++++++++++++++++++++ | ||
+ | CL0N01Factor1+++++++Opcode(E)+Factor2+++++++Result++++++++Len++D+HiLoEq.. | ||
+ | OFilename++DF..N01N02N03Excnam++++B++A++Sb+Sa+........................... | ||
+ | O..............N01N02N03Field+++++++++YB.End++PConstant/editword/DTformat | ||
+ | </code> | ||
+ | |||