advanced rpg chapter 8
TRANSCRIPT
-
7/30/2019 Advanced RPG Chapter 8
1/24
Chapter 8
Interactive Applicatons
-
7/30/2019 Advanced RPG Chapter 8
2/24
Batch Processing: Program is run without
human intervention or control.
Interactive Processing: User driven
Display files are needed for interaction.
Screen Design Aid (SDA): Graphical utility that
will generate DDS source code.
-
7/30/2019 Advanced RPG Chapter 8
3/24
You can have multiple record formats per
DDS member.
-
7/30/2019 Advanced RPG Chapter 8
4/24
Section Inquiry
Type value, then Enter.
Section number . . ____________
F3=Exit
-
7/30/2019 Advanced RPG Chapter 8
5/24
Section Information
Section number . . . . . 12435
Course . . . . . . . . . BIS350
Instructor . . . . . . . . Johnson
Room . . . . . . . . . . 1120
Meets on days . . . . . . MWF
Starting Time . . . . . . . 10:30
Enrollment . . . . . . . . 36
Press Enter to Continue
F3=Exit F12=Cancel
-
7/30/2019 Advanced RPG Chapter 8
6/24
AAN01N02N03T.Name++++++RLen++TDpBLinPosFunctions+++++++++++++++++
********** Beginning of data ************************************
A REF(SECTIONS)
A INDARA
A R SECT1
A CA03(03 'F3=EXIT')
A 1 28'SECTION INQUIRY'
A 3 2'TYPE VALUE, THEN ENTER.'
A 5 5'SECTION NUMBER . .'
A SECTION 5A I 5 24
A 23 2'F3=EXIT'
-
7/30/2019 Advanced RPG Chapter 8
7/24
AAN01N02N03T.Name++++++RLen++TDpBLinPosFunctions++++++++++++++++++
A R SECT2A CA03(03 'F3=EXIT')
A CA03(12 'F12=CANCEL')
A 1 10'SECTION INFORMATION'
A 3 2'SECTION NUMBER . . .'
A SECTNO R O 3 29
A 3 2'COURSE . . . . . . .'
A COURSE R O 4 29
A 5 2'INSTR . . . . . . .'
A INSTR R O 5 29
A 6 2'ROOM . . . . . . .'
A ROOM R O 6 29
A 7 2'MEETS ON DAYS . . .'
A DAYS R O 7 29
A 8 2'STARTING TIME . . .'
A BEGTIME R O 8 29A 9 2'ENROLLMENT . . . . .
A ENROLL R O 9 29
A 21 2'PRESS ENTER TO CONTINUE'
A 23 2'F3=EXIT'
A 23 11'F12=CANCEL'
-
7/30/2019 Advanced RPG Chapter 8
8/24
CA03(03 F3=EXIT)
CA: Command Attention, enables the
function key of F3. Returns control to RPGprogram without passing user input values.
When F3 is pressed by the user, indicator 03
is turned on.
F3=EXIT: Programmer comment.
-
7/30/2019 Advanced RPG Chapter 8
9/24
CF03(03 F3=EXIT)
CF: Command Function
Functions the same as CA03 except that thevalues the user has inputted are passedback to the RPG program.
CA12(12 F12=Cancel) Generally used to move the user back a
screen.
-
7/30/2019 Advanced RPG Chapter 8
10/24
Display files are defined in File Specs just likeany other file. Full Procedural
Externally defined
Key is not relevant (position 34 blank)
type (position 17) is C for combined file, supportsboth input and output but as independentoperations.
Optional keyword INDDS: Stores indicators passedto and from display file in data structure namedFkeys.
-
7/30/2019 Advanced RPG Chapter 8
11/24
Interactive programs are prone to
spaghetti code.
flow of control is not straight forward User can press F3 to Exit or F12 to Cancel
Causes programmer to back up, repeat or exit
early.
-
7/30/2019 Advanced RPG Chapter 8
12/24
WHILE user wants to continue (no Exit)
Display first screen
Obtain users response to the screen
IF user wants to continue (no exit)
Random read section file to get section information
IF record found
Display second screen
Obtain users response
ENDIF
ENDIF
ENDWHILE
-
7/30/2019 Advanced RPG Chapter 8
13/24
WHILE user wants to continue (no Exit) (*IN03 = *OFF)
Display first screen (EXFMT Sect1)
Obtain users response to the screen
IF user wants to continue (no exit) (IF *IN03 = *OFF)
Random read section file to get section information
(Section CHAIN Sections)
IF record found (IF %FOUND(Sections)
Display second screen (EXFMT Sect2)
Obtain users response
ENDIF
ENDIF
ENDWHILE
-
7/30/2019 Advanced RPG Chapter 8
14/24
Allowable functions for I/O
WRITE: Displays a screen and returns control to
program without waiting for user input.
READ: Sends control to currently displayed screenwaits for end of user input (usually triggered by
Enter key)
EXFMT: Combines WRITE/READ, first writes a
record to the screen and then waits for user input tothe screen, when signaled it returns control to RPG
program. USED MOST OFTEN!
-
7/30/2019 Advanced RPG Chapter 8
15/24
RPG IV gets away from referencingindicators
Must specify INDDS keyword in F Spec.
Indicator Data Structure in DDS (INDARA)
Define data structure in D Spec to contain
indicators.
Only have to define the ones you are using.
D FKeys DS 99
D Exit 3 3N
D Cancel 12 12N
-
7/30/2019 Advanced RPG Chapter 8
16/24
CL0N01Factor1+++++++Opcode&ExtExtended-factor2+++
C DOW NOT Exit
C EXFMT Sect1
C IF NOT Exit
C Section CHAIN Sections
C IF %FOUND(Sections)
C EXFMT Sect2C ENDIF
C ENDIF
C ENDDO
C EVAL *INLR = *ON
C RETURN
-
7/30/2019 Advanced RPG Chapter 8
17/24
File Level: Must be on first line of DDS, before Record Format
REF: reference another file for specifications
INDARA: organize indicators into 99-byte datastructure
MSGLOC: specifies message line for errormessages (default is last line, 24)
File or Record Level: CA or CF: coded at file level they will apply to all
record formats within the file PRINT: enables Print Key for user screen printing.
VLDCMDKEY: turns on indicator when userspresses any valid command key
-
7/30/2019 Advanced RPG Chapter 8
18/24
Record Level:
Appear on line record is named or lines
immediately following, prior to field names. BLINK: causes cursor to blink
OVERLAY: Display record without clearing
previous record display.
-
7/30/2019 Advanced RPG Chapter 8
19/24
Field Level:
Apply only to specific field it is associated.
EDTCDE, EDTWRD: format numeric output DSPATR: Display Attribute, determines
appearance. (BL blinking field, UL
underline)
DSPATR(BL UL)
-
7/30/2019 Advanced RPG Chapter 8
20/24
Field Level: Data Validation VALUES: Specify exact values allowed.
VALUES(value1 value2 . . .)
RANGE: Specify range of values allowed.
RANGE(low-value high-value) COMP: Relational comparison with inputted value
(EQ,NE,GT,NG,LT,NL,GE,LE): COMP(GT 100)
CHECK: Validity checking (ME, MF, AB)
CHECK(Validity code) ERRMSG:
TIME and DATE
-
7/30/2019 Advanced RPG Chapter 8
21/24
Conditioning Indicators:
Field Keyword will only apply if conditioning
indicator is turned on by the RPG program.
AAN01N02N03T.Name++++++RLen++TDpBLinPosFunctions++++++++++++++++++
-
7/30/2019 Advanced RPG Chapter 8
22/24
AAN01N02N03T.Name++++++RLen++TDpBLinPosFunctions++++++++++++++++++
********** Beginning of data *************************************
A REF(SECTIONS)
A PRINT
A INDARA
A R SECT1
A BLINK
A CA03(03 'F3=EXIT')
A 1 28'SECTION INQUIRY'A 3 2'TYPE VALUE, THEN ENTER.'
A 5 5'SECTION NUMBER . .'
A SECTION 5A I 5 24
A DSPATR(UL)
A DSPATR(HI)
A ERRMSG('SECTION NOT FOUND 90)
A 23 2'F3=EXIT'
A
A R SECT2A CA03(03 'F3=EXIT')
A CA03(12 'F12=CANCEL')
A 1 10'SECTION INFORMATION'
A 3 2'SECTION NUMBER . . .'
A SECTNO R O 3 29
A 3 2'COURSE . . . . . . .'
A COURSE R O 4 29
A 5 2'INSTR . . . . . . .'
A INSTR R O 5 29
A 6 2'ROOM . . . . . . .'
A ROOM R O 6 29EDTCDE(Z)
A 7 2'MEETS ON DAYS . . .'
A DAYS R O 7 29
A 8 2'STARTING TIME . . .'
A BEGTIME R O 8 29EDTWRD(' 0: ')
A 9 2'ENROLLMENT . . . . .'
A ENROLL R O 9 29EDTCDE(3)
A 21 2'PRESS ENTER TO CONTINUE'
A 23 2'F3=EXIT'
-
7/30/2019 Advanced RPG Chapter 8
23/24
DFKeys DS
D Exit 3 3N
D Cancel 12 12N
D SectNotFnd 90 90N
C DOW NOT ExitC EXFMT Sect1
C IF NOT Exit
C Section CHAIN Sections
C EVAL SectNotFnd = NOT %FOUND(Sections)
C IF %FOUND(Sections)
C EXFMT Sect2
C ENDIF
C ENDIF
C ENDDO
-
7/30/2019 Advanced RPG Chapter 8
24/24
Adding, changing or deleting records
instantly.
Must verify data validity Three methods of safeguarding
Validation Keywords in PF description
Validation Keywords in Display file description
Validating values in program