SoftCode Applications Continued
Database Driven Functions
The program function keys and macro instructions are contained in the data base file, SCFUNCPF. The program options and option macros are contained in the database file, SCOPTNPF. By removing the function keys and options from the program, the operations performed by the options and function keys may be maintained independently of the program itself.
Function key assignments and program options may be removed from the application without changing the program code. Conversely adding new functions or program options can be performed without changing the program code. (Unless a new parameter list happens to be introduced.)
Because the function editor manages a program’s options and functions, commands, such as DSPMSG, or WRKACTJOB may be added to a program without any change to existing program code. The Soft Code editor is coded to recognize a command (a string starting with an ampersand ‘&’) and execute the command. The program does not have to contain a routine to execute a command, the function editor with provide the capability. In effect, the database files supporting the Soft Code provide a method of building macro instructions for applications to share.
Another benefit of moving program functions and objects from the actual program (and display file) is the text of the function is stored with the function. The text displayed for the function or option is contained in the database along with the macro instruction. Thus a program can be designed to be multi-lingual. On one application the F3 (Exit) function may read ‘Exit’ and in another application the same function may read ‘Salida’ (Spanish), or ‘Ausgang’ (German).
A Soft Code application does not really react to a function key, or an option. The editor looks up the function key or panel option and returns the ‘function’ to the requesting program. This increases the flexibility of the application and allows it to be compatible with other system i environments. For example a program may be coded to exit when the macro instruction returned is ‘EXIT’. The macro ‘EXIT’ may be assigned to F3, to be consistent with AS/400 mode panels, or F7 (End Job) so it is familiar to users used to working in the S/36 environment.
The macro instruction field of the soft coded program options and function keys is 45 bytes long. This instruction may contain several different types of operations. And in SoftCode, the macro instruction may take several different formats. An ampersand '&' in byte 1 identifies a CL command. The Soft coded function editor will pass this command on to the generic command executive program to be processed.
000000000111111111122222222223333333334444444 123456789012345678901234567890123456789012345 &WRKACTJOB | |____________Command to process
An asterisk (*) in byte 1 signals a reserved function. Code has been included in the soft-coded function editor to process the macro instruction, it will not be returned to the requesting program.
000000000111111111122222222223333333334444444 123456789012345678901234567890123456789012345 *HELP | |____________Soft coded internal process
With no special characters imbedded in the instruction, the macro instruction will be returned to the requesting program for execution. In this case, the format is left to the requesting program to interpret. A standard format for macro instructions to drive subroutines is evident in the process of command keys and other common program operations.
ThisFormat = fmtnam; ThisPgm = prgnam; GetFunction(thisPgm :thisFormat :keypressed :fkeyid:macro:authl); [1] SELECT; WHEN KeyPressed = functionKey.ENTER; EXSR @ENTER; WHEN KeyPressed = functionKey.ROLLUP; EXSR @LOAD; WHEN KeyPressed = functionKey.ROLLDN; EXSR @DOWN; WHEN KeyPressed = functionKey.F23; DisplayOptions(option: z$opt1: z$opt2: O); WHEN KeyPressed = functionKey.F24; DisplayKeys(cmdkey: z$key1: z$key2: M); [2] WHEN Function = 'EXIT'; QUIT(); WHEN Function = 'CANCEL'; EXSR @return; WHEN Function = 'RESET'; EXSR @RESET; WHEN Function = 'PROMPT'; EXSR @PROMPT; IF promptDta <> *blanks; PromptDta = *blanks; EXSR @RESET; ENDIF; WHEN Function = 'HELP'; HelpText(ThisPgm:fmt); WHEN SUBOP = 'CALL'; EXSR @CALLS; WHEN Function = 'CMDLINE'; CommandLine(); [3] ENDSL; CLEAR macro; ENDDO; Fig. 21