Program organization
A Synergy program contains one or more routines. A Synergy DBL routine contains two main parts: a data division and a procedure division. The data division defines most of the data structures that will be used in the program. The procedure division contains the executable statements and defines the processing algorithms, but you can also define local stack variables there if desired. The PROC statement indicates the end of the data division and the start of the procedure division.
You can define data externally in the S/DE Repository, and reference it in your program’s data division using the .INCLUDE compiler directive. (Refer to the Repository User’s Guide for more information about Repository.)
Modularity and structured programming
Synergy DBL encourages structured, modular programming, which divides a large program into smaller subroutines, functions, classes, and methods. The main routine is the main entry point into the program. Subroutines, functions, and methods are either called from the main routine or from other subroutines, functions, and methods. An external subroutine begins with the SUBROUTINE statement, a function begins with the FUNCTION statement, and a method inside a class begins with the METHOD statement. An internal subroutine begins with a label, and its code is part of the same program as the routine that calls it.
A Synergy program may contain multiple subroutines, functions, or methods and one main routine. Each main routine, subroutine, function, and method must end with an END, ENDMAIN, ENDSUBROUTINE, ENDFUNCTION, or ENDMETHOD statement.
An explicit main routine looks like this:
main Data division statements (optional) . . . proc Procedure division statements . . . endmain
In most cases the MAIN statement is optional. (A main routine without “MAIN” is an implicit main.) However, if the first thing in the data division is a STRUCTURE declaration, or if the main routine immediately follows an IMPORT statement, the MAIN keyword is required.
A subroutine or function looks like this:
subroutine mysub or function myfunc Data division statements (optional) . . . proc Procedure division statements . . . endsubroutine or endfunction
A method looks like this:
class myclass method mymethod ,void Data division statements (optional) . . . proc Procedure division statements . . . endmethod endclass
Bound programs
(traditional Synergy only) Binding is a method of grouping multiple main routines into one executable program. You can combine several Synergy DBL main routines into a single, bound program that can be executed using the dbr command. Binding and bound applications have the following features:
- A bound application has only one entry point; the rest of the main routines are considered “super subroutines.”
- Binding reduces chaining overhead (which on OpenVMS is quite high).
- Binding reduces the size of the executable file, because only one copy of the utility subroutines is used, instead of a separate copy for each individual main routine. (Note that ELBs and shared images also provide this feature.)
- All commons, global records, and global literals are loaded into one data area.
- All class definitions are combined into one table.
- Binding reduces class reference overhead after a chain on classes that have already been referenced.
Commons, global data sections, and classes must individually match other commons, global data sections, and classes of the same name. Only one GLOBAL COMMON and one GLOBAL DATA SECTION, INIT is allowed in a bound program.
See Binding for instructions on creating a bound program.