• Keine Ergebnisse gefunden

DATA STATEMEIIT

Im Dokument PICK BASIC reference manual (Seite 84-89)

subroutines and interprogram communication

A- LISTVERBS CHAIN A

5.3.2 DATA STATEMEIIT

The DATA statement is used to store data for queued input when using the CHAIN statement. The general form of the DATA statement is:

DATA expression

where 'expression' may be any valid combination of variables, literals, functions, etc.

Each DATA statement will generate one line of queued input. These input lines are then used in response to input requests from other processes. The DATA statement may be used to store queued input for ACCESS, TCL, PROCs, or other BASIC programs.

The following example illustrates the procedure to exit a BASIC program, sort select a file and begin execution of a second BASIC program. The variable REF-DATE is passed to the second BASIC program. Assuming that no queued input is currently present:

DATA 'RUN BP PROG'; DATA 'REF-DATE'

CHAIN 'SSELECT FILE WITH DATE "':REF.DATE:'" BY DATE'

The first statement queues two values (e.g., 'RUN BP PROG' and 'REF-DATE').

The second statement causes an ACCESS statement to be executed. This is

followed by input of the first value in the queue to the TCL prompt, beginning execution of BP PROG. Note that the queue is a First In First Out (FIFO) type, and therefore, the DATA statement must be processed before the CHAIN statement.

The second BASIC program (BP PROG) then performs the following:

INPUT REF-DATE

This instruction gets its input from the second value in the queue (i.e., the value of REF-DATE from the first BASIC program).

Multiple expressions are allowed on the DATA statement. Each expression becomes the response to one input request from the CHAINed process.

Multiple DATA statements take the form:

DATA x,x,x, •••

Examples of the use of DATA:

Correct Use DATA A DATA B DATA C

CHAIN 'RUN BP TEST'

DATA 'RUN BP CHARGE-ACC' DATA DATE

CHAIN 'SELECT ACC WITH AMT

>

100'

DATA A,B,C

Incorrect Use

CHAIN 'RUN BP PROG' DATA X

Explanation

Queues the values of A, B and C for subsequent input requests. Program 'TEST' may have three input requests which will be satisfied by the

queued input.

This causes the TCL command 'RUN BP CHARGE-ACC' to be stored in the queue.

Control first exits to the ACCESS processor to perform the SELECT, after which the BASIC program is run with DATE as queued input.

Multiple expressions may be queued by a single DATA statement.

Explanation

The DATA statement must be processed before the CHAIN statement.

5.3.3 COMMON STATEKElIT

The COMMON statement may be used to control the order in which space is allocated for the storage of variables and to pass values between programs.

The general form of the COMMON statement is:

COK{KON} variable {,variable} •••

The purpose of the COMMON statement is to change the automatic allocation sequence that the compiler follows, so that more than one program may have specified variables in a predetermined sequence.

In the absence of a COMMON statement, variables are allocated space in the order in which they appear in the program, with the additional restriction that arrays are allocated space after all simple variables. COMMON variables

(including COMMON arrays) are allocated space before any other variables in the program. The COMMON statement must appear before any of the variables in the program are used.

The COMMON variable list may include simple variables, file variables and arrays. Arrays may be declared in a COKMON statement by specifying the dimensions enclosed in parentheses. For example, COKMON A(10) declares an array "A" with 10 elements. Arrays that are declared in a COMMON statement should not be declared again by a DIMENSION statement. All variables in the program which do not appear in a COMMON statement are allocated space in the normal manner.

The COKMON statement may be used to share among main-line programs and subroutines.

variables refer to the same stored values 'I' option must be used with the RUN verb reinitialization. For example:

COMMON X,Y,Z(5) COt-IMON Q,R,S(5)

variables among CHAINed programs, or This ensures that all 'COMMON' statement therefore provides a more efficient method of passing values.

Examples of the use of COMMON:

Correct Use Item "MAINPROG"

COMMON A,B,C(10) A - "NUMBER"

B - "SQUARE ROOT"

FOR 1 - 1 TO 10 C(I) - SQRT(I) NEXT I

CALL SUB PRINT "DONE"

END

Item SUBPROG COMMON X(2),Y(10) PRINT X(l), X(2) FOR J - 1 TO 10

PRINT J, Y(J) NEXT J

RETURN

END

Incorrect Use COMMON A,B,C(10) DIM C(10)

Explanation

Variables A, B and array C are allocated space before any other variables.

Subroutine call to program SUBPROG.

The 2 elements of array X contain

respectively, the values of A and B from the main-line program. The array Y contains the values of C from the main-line program.

Returns to main-line program.

Explanation

A DIMENSION statement should not be used for an array which has already been declared in a COMMON statement.

5.3.4 ENTEll STADMElft

The ENTER statement permits transfer of control from one cataloged program to another cataloged program. The program that executes the ENTER statement must be executed via the cataloged verb in the user's MD. The two forms of the ENTER statement are:

ENTER program-name

where program-name is the item-id of the program to be ENTERed and, ENTER @variable

where variable has been assigned the program name to be ENTERed.

All variables which are to be passed between programs must be declared in a COMMON declaration in all program segments that are to be ENTERed. All other variables will be initialized upon ENTERing the program. It is permissible to ENTER a program that calls a subroutine, but it is illegal to ENTER a program from a subroutine.

Examples of the use of ENTER:

Correct Use ENTER PROGRAK.l

N-2

PROG - "PROGRAM." N ENTER @PROG

Incorrect Use ITEM-"ABC"

ENTER ITEM

ENTER-150

Explanation

Causes execution of the cataloged program

"PROGRAK.l". Any COMMON variables will be passed.to "PROGRAK.l".

Causes execution of the cataloged program

"PROGRAM.2". Any COMMON variables will be passed to "PROGRAM.2".

Explanation

Would cause execution of the cataloged program "ITEM", not "ABC". Must be the indirect form (with "@") if program name is stored in a variable.

ENTER cannot be used as a variable name.

intrinsic functions

6.1 NUMERIC FUNCTIONS

Im Dokument PICK BASIC reference manual (Seite 84-89)