advanced rpg chapter 8 interactive applicatons. interactive applications batch processing: program...

24
Advanced RPG Advanced RPG Chapter 8 Chapter 8 Interactive Applicatons Interactive Applicatons

Upload: rogelio-foxall

Post on 14-Dec-2015

215 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Advanced RPG Chapter 8 Interactive Applicatons. Interactive Applications  Batch Processing: Program is run without human intervention or control.  Interactive

Advanced RPGAdvanced RPG

Chapter 8Chapter 8

Interactive ApplicatonsInteractive Applicatons

Page 2: Advanced RPG Chapter 8 Interactive Applicatons. Interactive Applications  Batch Processing: Program is run without human intervention or control.  Interactive

Interactive ApplicationsInteractive Applications

Batch Processing: Program is run without Batch Processing: Program is run without human intervention or control.human intervention or control.

Interactive Processing: User drivenInteractive Processing: User driven Display files are needed for interaction.Display files are needed for interaction.

Screen Design Aid (SDA): Graphical utility that Screen Design Aid (SDA): Graphical utility that will generate DDS source code.will generate DDS source code.

Page 3: Advanced RPG Chapter 8 Interactive Applicatons. Interactive Applications  Batch Processing: Program is run without human intervention or control.  Interactive

Screen Design AidScreen Design Aid

You can have multiple record formats per You can have multiple record formats per DDS member.DDS member.

Page 4: Advanced RPG Chapter 8 Interactive Applicatons. Interactive Applications  Batch Processing: Program is run without human intervention or control.  Interactive

Screen Design AidScreen Design Aid

Section Inquiry

Type value, then Enter.Section number . . ____________

F3=Exit

Page 5: Advanced RPG Chapter 8 Interactive Applicatons. Interactive Applications  Batch Processing: Program is run without human intervention or control.  Interactive

Screen Design AidScreen Design Aid

Section Information

Section number . . . . . 12435Course . . . . . . . . . BIS350Instructor . . . . . . . . JohnsonRoom . . . . . . . . . . 1120Meets on days . . . . . . MWFStarting Time . . . . . . . 10:30Enrollment . . . . . . . . 36

Press Enter to Continue

F3=Exit F12=Cancel

Page 6: Advanced RPG Chapter 8 Interactive Applicatons. Interactive Applications  Batch Processing: Program is run without human intervention or control.  Interactive

Screen Design AidScreen Design Aid

AAN01N02N03T.Name++++++RLen++TDpBLinPosFunctions+++++++++++++++++********** Beginning of data ************************************A REF(SECTIONS)A INDARAA R SECT1A 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 24A 23 2'F3=EXIT'

Page 7: Advanced RPG Chapter 8 Interactive Applicatons. Interactive Applications  Batch Processing: Program is run without human intervention or control.  Interactive

Screen Design AidScreen Design AidAAN01N02N03T.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 29A 3 2'COURSE . . . . . . .'A COURSE R O 4 29A 5 2'INSTR . . . . . . .'A INSTR R O 5 29A 6 2'ROOM . . . . . . .'A ROOM R O 6 29A 7 2'MEETS ON DAYS . . .'A DAYS R O 7 29A 8 2'STARTING TIME . . .'A BEGTIME R O 8 29A 9 2'ENROLLMENT . . . . .‘A ENROLL R O 9 29A 21 2'PRESS ENTER TO CONTINUE'A 23 2'F3=EXIT'A 23 11'F12=CANCEL'

Page 8: Advanced RPG Chapter 8 Interactive Applicatons. Interactive Applications  Batch Processing: Program is run without human intervention or control.  Interactive

Screen Design AidScreen Design Aid

CA03(03 ‘F3=EXIT’)CA03(03 ‘F3=EXIT’) CA: Command Attention, enables the CA: Command Attention, enables the

function key of F3. Returns control to RPG function key of F3. Returns control to RPG program without passing user input values.program without passing user input values.

When F3 is pressed by the user, indicator 03 When F3 is pressed by the user, indicator 03 is turned on. is turned on.

‘‘F3=EXIT’: Programmer comment.F3=EXIT’: Programmer comment.

Page 9: Advanced RPG Chapter 8 Interactive Applicatons. Interactive Applications  Batch Processing: Program is run without human intervention or control.  Interactive

Screen Design AidScreen Design Aid

CF03(03 ‘F3=EXIT’)CF03(03 ‘F3=EXIT’) CF: Command FunctionCF: Command Function Functions the same as CA03 except that the Functions the same as CA03 except that the

values the user has inputted values the user has inputted areare passed passed back to the RPG program.back to the RPG program.

CA12(12 ‘F12=Cancel’)CA12(12 ‘F12=Cancel’) Generally used to move the user back a Generally used to move the user back a

screen.screen.

Page 10: Advanced RPG Chapter 8 Interactive Applicatons. Interactive Applications  Batch Processing: Program is run without human intervention or control.  Interactive

Screen Design AidScreen Design Aid Display files are defined in File Specs just like Display files are defined in File Specs just like

any other file.any other file. Full ProceduralFull Procedural Externally definedExternally defined Key is not relevant (position 34 blank)Key is not relevant (position 34 blank) type (position 17) is C for combined file, supports type (position 17) is C for combined file, supports

both input and output but as independent both input and output but as independent operations.operations.

Optional keyword INDDS: Stores indicators passed Optional keyword INDDS: Stores indicators passed to and from display file in data structure named to and from display file in data structure named Fkeys.Fkeys.

Page 11: Advanced RPG Chapter 8 Interactive Applicatons. Interactive Applications  Batch Processing: Program is run without human intervention or control.  Interactive

Screen Design AidScreen Design Aid

Interactive programs are prone to Interactive programs are prone to “spaghetti code”.“spaghetti code”. flow of control is not straight forwardflow of control is not straight forward User can press F3 to Exit or F12 to CancelUser can press F3 to Exit or F12 to Cancel

Causes programmer to back up, repeat or exit Causes programmer to back up, repeat or exit early.early.

Page 12: Advanced RPG Chapter 8 Interactive Applicatons. Interactive Applications  Batch Processing: Program is run without human intervention or control.  Interactive

Screen Design AidScreen Design AidWHILE user wants to continue (no Exit)

Display first screen

Obtain user’s 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 user’s response

ENDIF

ENDIF

ENDWHILE

Page 13: Advanced RPG Chapter 8 Interactive Applicatons. Interactive Applications  Batch Processing: Program is run without human intervention or control.  Interactive

Screen Design AidScreen Design AidWHILE user wants to continue (no Exit) (*IN03 = *OFF)

Display first screen (EXFMT Sect1)

Obtain user’s 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 user’s response

ENDIF

ENDIF

ENDWHILE

Page 14: Advanced RPG Chapter 8 Interactive Applicatons. Interactive Applications  Batch Processing: Program is run without human intervention or control.  Interactive

Screen Design AidScreen Design Aid

Allowable functions for I/OAllowable functions for I/O WRITE: Displays a screen and returns control to WRITE: Displays a screen and returns control to

program without waiting for user input.program without waiting for user input. READ: Sends control to currently displayed screen READ: Sends control to currently displayed screen

waits for end of user input (usually triggered by waits for end of user input (usually triggered by Enter key)Enter key)

EXFMT: Combines WRITE/READ, first writes a EXFMT: Combines WRITE/READ, first writes a record to the screen and then waits for user input to record to the screen and then waits for user input to the screen, when signaled it returns control to RPG the screen, when signaled it returns control to RPG program. USED MOST OFTEN!program. USED MOST OFTEN!

Page 15: Advanced RPG Chapter 8 Interactive Applicatons. Interactive Applications  Batch Processing: Program is run without human intervention or control.  Interactive

Screen Design AidScreen Design Aid RPG IV gets away from referencing RPG IV gets away from referencing

indicatorsindicators Must specify INDDS keyword in F Spec.Must specify INDDS keyword in F Spec. Indicator Data Structure in DDS (INDARA)Indicator Data Structure in DDS (INDARA) Define data structure in D Spec to contain Define data structure in D Spec to contain

indicators.indicators. Only have to define the ones you are using.Only have to define the ones you are using.

D FKeys DS 99

D Exit 3 3N

D Cancel 12 12N

Page 16: Advanced RPG Chapter 8 Interactive Applicatons. Interactive Applications  Batch Processing: Program is run without human intervention or control.  Interactive

Screen Design AidScreen Design AidCL0N01Factor1+++++++Opcode&ExtExtended-factor2+++C DOW NOT ExitC EXFMT Sect1C IF NOT ExitC Section CHAIN SectionsC IF %FOUND(Sections)C EXFMT Sect2C ENDIFC ENDIFC ENDDO

C EVAL *INLR = *ONC RETURN

Page 17: Advanced RPG Chapter 8 Interactive Applicatons. Interactive Applications  Batch Processing: Program is run without human intervention or control.  Interactive

DDS KeywordsDDS Keywords File Level:File Level:

Must be on first line of DDS, before Record FormatMust be on first line of DDS, before Record Format REF: reference another file for specificationsREF: reference another file for specifications INDARA: organize indicators into 99-byte data INDARA: organize indicators into 99-byte data

structurestructure MSGLOC: specifies message line for error MSGLOC: specifies message line for error

messages (default is last line, 24)messages (default is last line, 24) File or Record Level:File or Record Level:

CA or CF: coded at file level they will apply to all CA or CF: coded at file level they will apply to all record formats within the filerecord formats within the file

PRINT: enables Print Key for user screen printing.PRINT: enables Print Key for user screen printing. VLDCMDKEY: turns on indicator when users VLDCMDKEY: turns on indicator when users

presses any valid command keypresses any valid command key

Page 18: Advanced RPG Chapter 8 Interactive Applicatons. Interactive Applications  Batch Processing: Program is run without human intervention or control.  Interactive

DDS KeywordsDDS Keywords

Record Level:Record Level: Appear on line record is named or lines Appear on line record is named or lines

immediately following, prior to field names.immediately following, prior to field names. BLINK: causes cursor to blinkBLINK: causes cursor to blink OVERLAY: Display record without clearing OVERLAY: Display record without clearing

previous record display.previous record display.

Page 19: Advanced RPG Chapter 8 Interactive Applicatons. Interactive Applications  Batch Processing: Program is run without human intervention or control.  Interactive

DDS KeywordsDDS Keywords

Field Level:Field Level: Apply only to specific field it is associated.Apply only to specific field it is associated. EDTCDE, EDTWRD: format numeric outputEDTCDE, EDTWRD: format numeric output DSPATR: Display Attribute, determines DSPATR: Display Attribute, determines

appearance. (BL – blinking field, UL – appearance. (BL – blinking field, UL – underline)underline) DSPATR(BL UL)DSPATR(BL UL)

Page 20: Advanced RPG Chapter 8 Interactive Applicatons. Interactive Applications  Batch Processing: Program is run without human intervention or control.  Interactive

DDS KeywordsDDS Keywords Field Level: Data ValidationField Level: Data Validation

VALUES: Specify exact values allowed.VALUES: Specify exact values allowed. VALUES(value1 value2 . . .)VALUES(value1 value2 . . .)

RANGE: Specify range of values allowed.RANGE: Specify range of values allowed. RANGE(low-value high-value)RANGE(low-value high-value)

COMP: Relational comparison with inputted value COMP: Relational comparison with inputted value (EQ,NE,GT,NG,LT,NL,GE,LE):(EQ,NE,GT,NG,LT,NL,GE,LE): COMP(GT 100)COMP(GT 100)

CHECK: Validity checking (ME, MF, AB)CHECK: Validity checking (ME, MF, AB) CHECK(Validity code)CHECK(Validity code)

ERRMSG: ERRMSG: TIME and DATETIME and DATE

Page 21: Advanced RPG Chapter 8 Interactive Applicatons. Interactive Applications  Batch Processing: Program is run without human intervention or control.  Interactive

DDS KeywordsDDS Keywords

Conditioning Indicators: Conditioning Indicators: Field Keyword will only apply if conditioning Field Keyword will only apply if conditioning

indicator is turned on by the RPG program.indicator is turned on by the RPG program.

Page 22: Advanced RPG Chapter 8 Interactive Applicatons. Interactive Applications  Batch Processing: Program is run without human intervention or control.  Interactive

AAN01N02N03T.Name++++++RLen++TDpBLinPosFunctions++++++++++++++++++********** Beginning of data *************************************A REF(SECTIONS)A PRINTA INDARAA R SECT1A BLINKA 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 24A DSPATR(UL)A DSPATR(HI)A ERRMSG('SECTION NOT FOUND‘ 90)A 23 2'F3=EXIT'AA 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 29A 3 2'COURSE . . . . . . .'A COURSE R O 4 29A 5 2'INSTR . . . . . . .'A INSTR R O 5 29A 6 2'ROOM . . . . . . .'A ROOM R O 6 29EDTCDE(Z)A 7 2'MEETS ON DAYS . . .'A DAYS R O 7 29A 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'A 23 11'F12=CANCEL'

Page 23: Advanced RPG Chapter 8 Interactive Applicatons. Interactive Applications  Batch Processing: Program is run without human intervention or control.  Interactive

Revised RPG codeRevised RPG code

DFKeys DSD Exit 3 3ND Cancel 12 12ND SectNotFnd 90 90N

C DOW NOT ExitC EXFMT Sect1C IF NOT ExitC Section CHAIN SectionsC EVAL SectNotFnd = NOT %FOUND(Sections)C IF %FOUND(Sections)C EXFMT Sect2C ENDIFC ENDIFC ENDDO

Page 24: Advanced RPG Chapter 8 Interactive Applicatons. Interactive Applications  Batch Processing: Program is run without human intervention or control.  Interactive

Interactive File Interactive File MaintenanceMaintenance

Adding, changing or deleting records Adding, changing or deleting records instantly.instantly. Must verify data validityMust verify data validity Three methods of safeguardingThree methods of safeguarding

Validation Keywords in PF descriptionValidation Keywords in PF description Validation Keywords in Display file descriptionValidation Keywords in Display file description Validating values in programValidating values in program