This section is intended for readers who are already familiar with non-S procedures; these are procedures that start with either of the commands PROCEDURE or BEGIN-PROCEDURE.
S procedures are essentially an enhancement of the existing procedure format that largely complies with the rules for high-level programming languages. Many non-S procedures can be converted to S procedures without major alterations (see chapter “Converting non-Sprocedures” (Converting non-S procedures )ff). However, to make the most of the intrinsic advantages of the new procedure format, some of the programming methods used most frequently in the “old” procedures must be adapted to permit the utilization of the new constructs offered by SDF-P. The table below shows the resultant enhancements:
Feature | Non-S procedures | S procedures |
Information storage | Procedure parameters (constants), job variables | S variables; job variables |
Control flow processing | Conditional and unconditional branches, error handling using spin-off and the SET-JOB-STEP command | Condition blocks, loops, GOTO, error handling using spin-off or return codes and error handling blocks |
Word processing | Editor call | String operators, predefined functions |
Arithmetics | Editor call, special programs | Integer operators, predefined functions |
Access to system output | Assignment of SYSOUT to file with subsequent editing | Structured output in S variables, predefined functions |
Procedure integrity checking | Call in SDF test mode | Variable and type declarations, preanalysis of control structures at calling time, call in SDF test mode |
Procedure debugging | ⎯ ⎯ ⎯ | Procedure test mode, tracing of individual steps |
The section “Format of an S procedure” contains a sample S procedure that outputs the last few lines of a text file to SYSOUT; both the name of the file and the number of lines to be output can be specified. To offer more or less the same functional scope, a non-S procedure would have to make use of certain TU programs, e.g. the EDT text editor. The sample procedure below shows how the functionality might be implemented in a non-S procedure and is intended to illustrate the contrast between non-S and S procedures:
/BEG-PROC LOG=*NO,PROC-PAR=(&FILE,&NUMBER=10),ESC-CHAR='&' /ASS-SYSDTA *SYSCMD /MOD-JOB-SW ON=(4,5) /START-EXEC-PROG $EDT @ SETSW OFF=4-5 @ PRO 1 @ 1.00 @N Analyze FILE parameter: @N either fully-qual. file name without gen/vers @N or '[*lib-elem](library,element[(vers)][,typ])' @@CR #S1 = '&FILE' @@ON #S1 F '(' @@IF .F. GOTO 3 @ 2.00 @N An element has been specified: @N extract library name @@#I1 = #I0 + 1 @@#I2 = L #S1 @@CR #S1: #S1:#I1-#I2: @@ON #S1 D R ')' @@IF .F. GOTO 4 @@ON #S1 F',' @@IF .F. GOTO 5 @@#I3 = #I0 - 1 @@CR #S2: #S1:1-#I3: @@#I3 = #I3 + 2 @@#I2 = L #S1 @@CR #S1: #S1:#I3-#I2: @N Load element @@PRO 11 @@CR 1: '@COPY L=', #S2, '(', #S1, ')' @@END @@DO 11 @@IF NO ERRORS: @GOTO 7 @@GOTO 6 @ 3.00 @N Load file @@READ '&FILE' @@IF NO ERRORS: @GOTO 7 @@GOTO 6 @ 4.00 @@CR #S1: 'Closing parenthesis after element spec is missing.' @@P #S1 N @@GOTO 6 @ 5.00 @@CR #S1: 'Comma between library name and element name is missing.' @@P #S1 N @@GOTO 6 @ 6.00 @@CR #S1: 'Error after loading "&FILE"!' @@P #S1 N @@GOTO 9 @ 7.00 @N Now specify line number where @N output is to start (not < 1!) @@#I1 = &NUMBER @@IF #I1 < 1 GOTO 9 @@#L1 = $ @@#S1 = C #L1 @@#I2 = S #S1:1-4: @@IF #I2 > #I1 GOTO 8 @N Output all @@P & N @@GOTO 9 @ 8.00 @N Output range @@#I1 = #I1-1 @@#L1 = $-#I1 @@P #L1.-.$ N @ 9.00 @@N @ END @ DO 1 @N Cleanup (otherwise there will be a query upon @HALT) @ DROP ALL @ HALT /SET-JOB-STEP /MOD-JOB-SW OFF=(4,5) /END-PROC