You are here: Development Standards > OSAS Standards > Program Structure > Code Section Details

# Code Section Details

Fixed groups of code are areas in the main program that are used for specific purposes. Because they provide a consistent method of performing particular tasks, the user can expect a consistent response to a similar condition regardless of the application.

Most code is executed in a linear fashion. The fixed routines are accessed in one of these ways: GOSUB, GOTO, SETERR or ERR=.

Remarks

0010–0029 | Program identification
The standardized method of identifying each program helps you administratively. Below is a sample of the identification area and a description of each line. The program identification area uses line numbers 0010–0029. Open Systems reserves line numbers 0010–0024.
    0001 SETERR GENERROR
    0010 REM "GLACG - 02/13/2003 - G/L MASTER FILE ADD/CHANGE"
    0011 REM "Authors - R1 - TRS, TAB, DSL, AWP, GL, DJB"
    0015 REM 0 - (COPYRIGHT) 0015-0029
    0016 REM "Standards 7.60"
    0019 REM "OPEN SYSTEMS (R) Accounting Software"
    0020 REM "Copyright (c) 1982 - 2011 Open Systems Holdings Corp.”
    0021 REM "All Rights Reserved"
    0022 REM "OPEN SYSTEMS is a registered trademark of Open Systems Holdings Corp."
0010 | Program name and description
`GLACG` | the full program name, including the extension when applicable
`02/13/2003` | the last date this program was modified
0011 | Author and copyright
`R1` | the QA round number of the program
`TRS` | the original author's initials
`TAB,..,DJB` | the programmers who have made major changes
0015 | Copyright signature line, used by the library manager
0016 | Standards version number
`Standards 7.60` | the standards version number
0019 | Trademark line
Enter exactly as shown. |
0020 | Copyright
`1982 - 2011` | the original copyright year, followed by a hyphen, followed by the most recent copyright year
0021-0022 | Copyright and Open Systems trademark line
Enter exactly as shown. |

Follow these rules when you change lines in the program identification area:

- When you change a program, change the development date to the date you made the change. The operating system date (the date the program was saved) should match the date on line 10.
- Change the round number when you change a program and submit it to QA.
- Add the author's initials only when you modify the program significantly; which usually corresponds to a major revision.

Copyrights

As a developer creating products for distribution by Open Systems (or with the approval of Open Systems) or for use with OSAS, you may use copyrighted Open Systems programs and modules in your product, but you must not remove the Open Systems copyright notices, and you must have licensed products.

All copyrights are and shall remain the exclusive property of Open Systems Holdings Corp. You must acknowledge all copyrights of Open Systems in a form substantially similar to this:

- Product name
- Copyright years
- Open Systems Holdings Corp. All rights reserved.

Any unauthorized use or duplication constitutes infringement of Open Systems copyrights. Open Systems will prosecute anyone responsible for infringing its copyrights. Open Systems conveys authorization to use Open Systems programs by contract (between the ISV and Open Systems) and by licensing the end user.

To avoid infringing Open Systems copyrights, you have two alternatives:

- Enter into a contract with Open Systems authorizing you to use Open Systems copyrighted matter (for example, program code).
- Be sure that the licensee's product contains the section of code shown below. Failure to report unauthorized use may make you liable for copyright infringement.

Add code lines 13 and 14 in OSAS programs that you have modified but not renamed. They must contain the modification information as defined here:

`0013 REM "[Programmer initials] - [Date last changed] - [your product's name]"`
`0014 REM "Copyright [year], [your company name]"`

Any OSAS program you have renamed for other use or used as a template to build a new program must show the old name on line 14 of the new program.

If you modify an Open Systems software program or application and sell it to a user or install it on a system, you must license the original source program and application for use by that user on that system. Failure to do so constitutes an infringement of Open Systems copyrights.

End-User License

These are the conditions of an end-user license:

- The user may operate and modify the software for internal use only.
- You may not post software to a higher-level machine unless you purchase a licensed upgrade for that machine.
- You may not transfer software to another machine unless you remove it from the original machine.
- You may not sell, resell, or barter software unless Open Systems approves a license transfer from one entity to another.

ISV License

An independent software vendor can purchase a license to modify Open Systems software from Open Systems in two ways:

- Contact Open Systems directly for a special-use contract. License rights provided are dependent on the contract.
- Purchase the appropriate version of the Advanced Developer Tool Kit and submit the appropriate information to Open Systems. Once approved by Open Systems, the ISV may modify, reuse, and resell Open Systems code, file structures, and general routines. However, the ISV may do so only in new enhancements, modifications, or applications installed over a licensed copy of the source program, data file, and application used (no exceptions). You must sell and license the base Open Systems application for the user before using software based on OSAS programs on that system.

Any other use of Open Systems software programs, data structures, general routines, user's guides, marketing literature, or other copyrighted product component constitutes copyright infringement. Open Systems will pursue legal action to protect its copyrights.

For your protection, include your own remarks and copyrights at the top of new programs that don't use any Open Systems code. The normal remark positions are lines 10–29.

0030-0089 | Comments describing program

Use line numbers 0030–0089 for program-specific identification purposes. Use this area to describe the separate pieces of the function, the inter-program control (if any), and the important non-file variables used.

Initialization

0090-0099 | Display screen/inter-program control/last-year file logic

The title assignment and the call to draw the screen occur here. The screen title should be assigned to the variable TITLE$. In version 5.00 and above you can set TITLE$=OT$; OT$ is the function title as passed from the RMMENU program.

When chaining between many programs in the same task, sometimes you must know the level of reentry being performed. The program control variable P9 is used. These lines of code can contain tests on P9 that will control where execution is passed to next.

In General Ledger, Payroll, and other applications the system must check for the use of last- or current-year files. This logic is added here.

0100-0299 | Open files (see GENOPEN)

All files should be opened in this section of the program. Report and post programs can use the 4000 section for file opens.

0300-0399 | Variable initialization

Define the necessary variables before main processing.

0400-0499 | Define functions (DEFFNx)

Define the programmer-defined functions.

0500-0898 | (see Specific Program Models)

This section is for special uses as per program task type.

0899-0999 | IOLISTs

Each application may have a common, predefined IOLIST section for the entire application. This section should contain IOLISTs for all files that may be interfaced by this application, including interfaces with other applications. Provide this common section with the application in the xxLIB file, which then can be used in any new program developed for the application. This procedure eliminates the need to change IOLISTs manually for file additions. All programs in an application should have the same IOLIST section.

Applications that use string templates for file access either have no IOLIST section or have an abbreviated section with IOLISTs for other applications.

Each IOLIST line number and label must be unique in the application. It should never be different between two programs. Another application's file may use the same line number if it is not interfaced with the contending application.

Each program that accesses data files uses the IOLIST group of code (if it does not use string templates to access the file). The IOLIST code always resides in lines 0899–0999, which are reserved for this purpose. Do not use these lines for any other purpose, even if you don't use IOLISTs in the program. The standard IOLIST code group is built up of all the IOLISTs from all the data files that are accessed in an application. The IOLIST code placed in any program starts with this standard code group. If a program is tight on memory or does limited I/O to files, you can delete unused IOLISTs from the standard code group.

Alternate IOLISTs can be used in programs. Use ALTxxxxx: as the label format. Standardize them where possible and provide them in the application's library of common routines in the IOLIST xxFIL code section. The goal is to have one source of IOLISTs for all programs in the application.

The first line of the code, 0899, is always the signature line, which describes the contents of the IOLIST code group.

`0899 REM 0 - (BRFIL) 0899-0999`

Each application was originally assigned a group of 10 line numbers for its data files. Because there are now more than 10 applications, some groups of line numbers have been reused or added to. Originally the line number was allocated based on the number on which the file was opened. Now we use line labels. Each IOLIST must have a unique label. The format is [BRBAX:].

Some application functions require an auxiliary set of IOLISTs (for temporary files, for example). They can be numbered in the 990–999 range outside the usual range for the application. If you need an IOLIST from another application, use it exactly as it is in the original application's IOLIST code group. It can be moved to another line number if contention occurs. The label must be unique.

The IOLIST statement is constructed by listing each variable in the data file in the order it is stored in the data file. General practice is to name the variables in each IOLIST statement with the same first letter so that all the variables for a file can be readily identified by the first letter.

It is standard practice for keyed files to define the first variable equal to the primary key of the file. The key to the file is generally a string variable with the same starting letter as the rest of the variables in the IOLIST and a zero (for example, A0$ for a file defined with the letter A).

The IOLIST statement may use the ALL construct for arrays. This is the IOLIST for the ARTRx file:

`0925 ARTR: IOLIST R0$,R0,R1$,R1[ALL],R2$,R3$,R2[ALL],R3,R4$,R4,R5[ALL],R5$,R6$`

Follow these guidelines when you use the ALL construct:

- The same technique is used for string arrays.
- The array must be dimensioned to the proper number of elements before using the IOLIST. DIM R1[2] is not the same as DIM R1[1:2].
- Each element of a dimensioned array must be listed in the IOLIST with no other variables between array references.
- The variables used in an application must be unique for all files in that application.

Main Processing

1000-5999 | (see "Specific Program Models")

Put DIMension statements at 1010–1099 after an ABANDON: line label and before a PAGEUP: label. This allows 'S' logic to GOTO PAGEUP and not clear out any variables. 'X' logic can GOTO ABANDON and clean up all variables.

Insert your processing code in this section. Use GOSUB and CALL to access general routines when desired.

Use top-down logic.

General Routines and Reserved Areas

6000-6099 | GENINPUT routine (see "General Routines")
6200-6299 | GENINFO routine (see "General Routines")
6300-6399 | DRILL routine for GL Drill down or Report loading of report defaults
6400-6499 | Retrieve report pick screen defaults
6500-6699 | Additional subroutine area
6700-6799 | GENLINE routine (see "General Routines")
6800-6999 | Additional subroutine area
7000-7499 | Reserved for future routine

Text Screen

Each program that has an input screen uses the following routines to draw the screen in text mode. The code always resides in lines 7500–7999, which have been reserved for this purpose. These lines are used for other purposes when screen display is not done in a program. The screen display routines are made up of these three routines:

7500-7699 | Print Prompts (see "Coding Conventions")

This routine is used to display the field prompts on the text screens on a user's terminal. This section of code can be called from anywhere in the main program.

7700-7899 | Print data (see "Coding Conventions")

This routine is used to display data on the text screens on a user's terminal. This section of code can be called from anywhere in the main program to refresh data.

7900-7999 | Print boxes (see "Coding Conventions")

This routine is used to display the box and line graphics on the text screens on a user's terminal. It should be called only from the print prompts section defined above. Some programs that perform only initialization may contain just the Print Boxes routine so that the task title appears before any OPEN errors are reported. If all is okay, the next program can paint the prompts and field names.

General Routines

8300-8399 | GENOPEN routine (see "General Routines")
8400-8499 | GENERROR routine (see "General Routines")
8500-8999 | (see "Specific Program Models")
9000-9199 | GENDATE routine (see "General Routines")
9300-9399 | GENLOCK routine (see "General Routines")
9400-9599 | GENPC routine (see "General Routines")
9600-9989 | Reserved for use during program development.

Exit

9990-9998 | Exit from program - (usually RUN O1$)
9999 | END statement

General Routine

10000-10099 | GENNUM routine (see "General Routines")
10100-10299 | GENPHONE routine (see "General Routines")

GUI Screen

Each program that has a GUI input screen uses the following routines. The code always resides in lines 17500-17899, which have been reserved for this purpose. These lines are generally not used in other program models. The GUI screen display routines are made up of these two routines:

17500-17699 | Print GUI Prompts (see "Coding Conventions")

This routine is used to display the GUI screen on a user’s workstation. This section should be accessed only from the PROMPTS (7500) section of code, and only after checking to see if the variable GUI is set.

17700-17899 | Print GUI Data (see "Coding Conventions")

This routine is used to display data on GUI screens on the user’s workstation. This section should be accessed only from the DATA (7700) section of code, and only after checking to see if the variable GUI is set.

GUI Procedures

Several procedures are used to control the way in which a GUI screen is displayed and how it reacts to user input. These common routines are always found in lines 18000-18555.

18000-18099 | Disable Fields (see "Coding Conventions")

This routine enables only the key field and disables all other fields on a GUI screen. This section is usually called from the ABANDON section of code. Several routines may be used in this section to disable blocks of fields at a time depending on where the user is on the screen.

18100-18199 | Enable Fields (see "coding Conventions")

This routine disables only the key field and enables all other fields on GUI screens. This section is usually called after the user enters a key field, which is after the PAGEUP label in many programs. This section may contain more than one routine to enable blocks of fields depending on the user’s actions.

18200-18250 | Clear Global (see "Coding Conventions")

This routine is used to clear STBL(“DESTID”). On a GUI screen, if the user clicks to move from one field to another, this global variable contains the control ID that the user clicked. The program uses this ID to determine whether the program control must move forward or backward to get to the proper field. The variable’s contents must be cleared when program execution is interrupted by the program, such as when field contents are invalid or when messages appear on the screen.

18400-18450 | Destroy Screen (see "Coding Conventions")

This routine is used to hide or destroy GUI Screen that are currently in use in an application. This routine can be found in programs where forms pop up on top of other forms, and need to be hidden once the user has completed the function.

18500-18555 | Set up buttons (see "Coding Conventions")

This routine DIMensions and sets up the GUI_BUTTON$[ALL] array. This array contains control ID’s and character keystroke equivalents for HLE screens or other screens that contain scroll regiond (primarily inquiry functions).

GUI Functions

Several functions are also provided to streamline the presentation of data in certain controls. These functions are:

18800-18850 | GENCHECK (see "Coding Conventions")
18850-18890 | GENCHECK RADIO (see"Coding Conventions")
18900-18950 | GENLIST (see "Coding Conventions")

Future Space

20000-59999 | Additional subroutine area
60000-64299 | Reserved for future utilities
64300-64399 | Used by _EDIT
64400-64434 | Reserved for future use
65535 | Internal END statement (PRO/5 only)