Program. DORIC 9.65, INFO-Text software
Reklaam
Reklaam
PROGRAM
PROG
RAM PG_name
PROG
RAM [SECTION] [section_number]
creates a new INFO program or starts a new section in an existing
INFO program.
arguments
PG_name the name of the program to be created.
[SECTION] [section_number] used within a program for documentation or ease of understanding (e.g., PROGRAM
SECTION TWO, PROG ODD or PROG EVEN.
notes
n
An unqualified PROGRAM statement is allowed only when you are writing the program. It takes you to the next program section.
discussion
Odd numbered program sections
n
Use the CHANGE or EDIT commands to change a program. See the COMPILE and RUN commands for information on executing a program.
An INFO program is a sequence of INFO commands stored in a file. INFO executes the commands when you run the program. The PROGRAM command creates the program file.
INFO programs contain one or more sequentially numbered sections. There are two types of sections: oddnumbered sections and even-numbered sections. Program section one is an odd-numbered section, program section two is an even-numbered section, and so on. The two types of sections function differently.
In an odd-numbered program section, INFO processes each command on the entire set of selected records before processing the next command. This is the same as issuing a series of commands in an interactive session. It is best to format and initialize system variables, select and relate data files, and report results (by running reports or special forms) of processing in odd-numbered program sections.
INFO Reference Manual Commands 401
PROGRAM
Even numbered program sections
Create a program
In an even-numbered program section, INFO executes all of the commands in the even section once for each selected record. If the program changes a record during an even section, INFO rewrites the record at the end ofthe even section before reading the next selected record. It is best to update data files and do repetitive reporting (using
FC or PRINT commands) and transaction processing in even-numbered program sections.
To create a new program, enter the PROGRAM command followed by a program name. The program name must be
1- to 32-characters long and be unique to your directory.
INFO starts program section one and displays:
10000 PROGRAM SECTION ONE >
At the prompt, enter a valid program command keeping in mind odd-numbered and even-numbered section processing differences. See 'Execution modes for INFO commands' to determine which commands are legal in which program section. If you enter a command that is invalid for the current program section, INFO issues an error message and prompts you for a new command.
Continue entering commands until you want to go to the next program section or end the program. To go to the next program section, enter the PROGRAM command at the > prompt. To end the program, enter <RETURN> at the > prompt. If you end a program on an even-numbered section, INFO generates a PROGRAM END statement after you compile the program.
INFO determines the odd/even-numbered section sequence by the placement of the PROGRAM commands.
For example, the first PROGRAM command starts program section one, the second PROGRAM command starts program section two, and so on.
INFO also numbers each line in the program in increments of one starting with 10000 for program section one, 20000 for program section two, and so on. However, you do not see these numbers, except for the number 10000, while you create the program. You see them when you display the program (using the TYPE command).
402 Commands INFO Reference Manual
PROGRAM
PROFILE and
WRAPUP
There are two special programs you can create, named
PROFILE and WRAPUP. After you enter an INFO user name at the ENTER USER NAME > prompt, and before you see the first ENTER COMMAND > prompt, INFO searches your user area for a program named PROFILE.
If INFO finds it, the PROFILE program is immediately executed; as it ends, you see the ENTER COMMAND > prompt to begin your INFO session. You can use
PROFILE programs to begin menu-driven applications.
When you enter the QUIT command, INFO searches your user area for a program named WRAPUP. If INFO finds it, the WRAPUP program is immediately executed; as it ends, your INFO session ends, and you see either the
ENTER USER NAME > prompt or you return to operating system level if you included STOP with the QUIT command. The PROFILE and WRAPUP facilities are useful for doing routine maintenance of the files in your user area at the start and end of your INFO sessions.
INFO programming notes
n
Format any system variable you use before you reference it.
n
To reduce system overheads, avoid selecting and relating the same data files more than once in a program.
n
Cancel data file relationships when you no longer need them. This also reduces system overheads.
n
If you do not expand the command line for a report or a special form to include where to send the output and other execution options, the report is sent to your screen.
INFO Reference Manual Commands 403
PROGRAM examples
Creating a program:
ENTER COMMAND >PROGRAM P.PAYROLL
10000 PROGRAM SECTION ONE
>SELECT D.PAYROLL
>RESELECT FOR PAY-STATUS = 'E'
>FORMAT $NUM1,12,N,2
>CALCULATE $NUM1 = 0
>PROGRAM SECTION TWO
>IF DEPT LT 9000
> CALCULATE $NUM1 = $NUM1 + NET
> MOVE '*' TO PAY-STATUS
>ENDIF
><RETURN>
see also
The program after you compile and run it:
ENTER COMMAND >TYPE P.PAYROLL
PROGRAM NAME: P.PAYROLL 10/ 8/96
10000 PROGRAM SECTION ONE
10001 SELECT D.PAYROLL
10002 RESELECT FOR PAY-STATUS = 'E'
10003 FORMAT $NUM1,12,N,2
10004 CALCULATE $NUM1 = 0
20000 PROGRAM SECTION TWO
20001 IF DEPT LT 9000
20002 CALCULATE $NUM1 = $NUM1 + NET
20003 MOVE '*' TO PAY-STATUS
20004 ENDIF
99999 PROGRAM END
CHANGE
EDIT
COMPILE
RUN
DECODE
404 Commands INFO Reference Manual
Laadi alla
Reklaam