• Aucun résultat trouvé

Purpose: Displays a line for editing.

Versions: Cassette

***

Disk

***

Advanced Compiler

***

Format:

Remarks:

EDIT line

line is the line number of a line existing in the program. If there is no such line, an Undefined line number error occurs.

EDIT simply displays the line specified and positions the cursor under the first digit of the line number.

The line can then be modified as described under

"The BASIC Program Editor" in the BASIC Handbook.

A period C.) can be used for the line number to refer to the current line. For example, if you have just entered a line and wish to go back and change it, the command EDIT redisplays the line for editing.

LIST can also be used to display program lines for changing. See "LIST Command."

END

Statement

Purpose: Terminates program execution, closes all files, and returns to command level.

Versions: Cassette

***

Disk

***

Advanced

***

Compiler (**)

Format: END

Remarks: END statements can be placed anywhere in the program to terminate execution. END is different from STOP in two ways:

• END does not cause a Break message to be printed.

• END closes all files.

An END statement at the end of a program is optional. BASIC always returns to command level after an END is executed.

Example: This example ends the program if K is greater than 1,0,0,0; otherwise, the program branches to line number 2.0.

100 IF K>1000 THEN END ELSE GOTO 20

ENVIRON

Statement

Purpose: Modifies parameters in BASIC's environment table.

ENVIRON is used to change the "PATH" parameter for a child process or to pass parameters to a child process by inventing a new environment parameter.

See ENVIRON$, SHELL, and the DOS PATH Command.

Not valid for releases earlier than 3 .

.0.

Versions: Cassette Disk Advanced Compiler

Format:

Remarks:

*** ***

ENVIRON parm

=

string

parm

string

is the name of the parameter, such as

"PATH".

is the text that defines the new parameter.

parm must be separated from string by an equal sign or a blank. ENVIRON takes everything left of the first blank or equal sign as parm. The first "nonblank, nonequal" after parm is taken as string.

If string is a null string or consists only of

";" (a single semicolon), such as:

"PATH:;:;!!

ENVIRON

Statement

If parm does not exist, the new parameter is added at the end of the environment table.

If parm exists, it is deleted, the environment table is compressed, and parm is added at the end.

Note: When BASIC is invoked, the size of its environment table is the current size of DOS's environment table (rounded up to the next 16-byte paragraph boundary.) BASIC cannot expand its environment table. If you wish to add elements to BASIC's environment table, you must expand the table from DOS to the size your application needs before invoking BASIC.

Example: You can create a default PATH to the root directory on drive A with the following statement:

ENVIRON IIPATH=A: \ II

Now, you can invoke DOS from your BASIC program using the SHELL statement and issue any valid DOS command. If a disk file is needed to execute the command, DOS now automatically searches for it (.COM, .EXE, or .BAT) in the root directory on drive A if it is not on the current drive or directory.

ENVIRON

Statement

SHELL IInvokes a copy of COMMAND.COM.

A> REM Changes directory to IIWORK II on drive B.

A> CD B: \ WORK

B> REM Loads PROJI under DEBUG even though no drive is specified. DEBUG and PROJI are located on different drives.

B> DEBUG PROJI

B> REM Return to BASIC program

B> EXIT (exit DOS, return to BASIC program.) You can add a new parameter to the environment table:

ENVIRON IIHELP = C:\HELpll Idefines

file parameter called IIHELp ll CHOIR ENVIRON$ ("HELplI) Ichanqes dir to "HELP"

You can delete this parameter in the table by:

ENVIRON IIHELP=; II I del etes parameter "HELP"

from table

The environment you create from your BASIC application is passed to COMMAND.COM when it is invoked by the SHELL statement. This makes it possible to pass parameters from a parent (BASIC) to a child through the environment table.

Note: For related information, see also

"ENVIRON$ Function" and "SHELL Statement" in this manual. Also "SET

Command" in Disk Operating System Reference

ENVIRON$

Function

Purpose: Retrieves and displays the specified string from BASIC's environment table.

Not valid for BASIC releases earlier than 3 .

.0.

Versions: Cassette Disk Advanced Compiler

Format:

Remarks:

*** ***

v$ = ENVIRON$ (parm) or

v$ = ENVIRON$ (n)

parm

n

is a string expression containing the parameter to be retrieved.

is an integer expression returning a value in the range 1 to 255.

If a string argument is used, ENVIRON$ returns, from the environment table, a string containing the text that follows parm. If parm is not found or no text follows the equal sign, the null string is returned.

If a numeric argument is used, ENVIRON$ returns a string containing the nth parm from the environment table, along with the parm= text. If there is no nth parm, a null string is returned.

ENVIRON$ distinguishes between uppercase letters and lowercase letters. If you add to the table in this format:

ENVIRON$

Function

ENVIRON$ "load = high"

and want to check to see if the operation was

successful, you can use the ENVIRON$ function like this:

PRI NT ENV I RON (Ill oad II)

But if you type:

PRINT ENVIRON$ ("LOAD")

ENVIRON$ returns a null string because 'LOAD"

is not in the table; however, "load" is in the table.

Example: When DOS loads initially, it sets a parameter called

"COMSPEC" that tells DOS where to locate the COMMAND. COM file, and it sets up a null path.

To observe the contents of the environment table at start-up time, enter the following from BASIC:

PRINT ENVIRON$ (1)

You now see printed on the screen:

PATH=

If you enter:

PRINT ENVIRON$ (2) you see displayed:

COMSPEC = A:\COMMAND.COM

ENVIRON$

Function

If you enter:

PRINT ENVIRON$ ("COMSPEC") the computer's response is:

A: \ COMMAND. COM

The following program saves BASIC's environment table in an array so that it can be modified for a child process. After the child process is completed, the environment is restored.

10 DIM TABLE$(10) I assume no more than 10 parms 20 PARMS = 1 'initial number of parameters 30 WHILE LEN(ENVIRON$(PARMS)) > 0

40 TABLE$(PARMS) = ENVIRON$(PARMS) 50 PARMS = PARMS+1

60 WEND

70 PAR M S ~: PAR M S- 1 I d d jus t t (j C 0 (' (' e c t n urn bey 80 Inow store new environment

90 ENVIRON "DATAIN = C:\DATAIN\INP.FIL"

100 ENVIRON "SORT.DAT

=

SORT.DAT<" + ENVIRON$ ("DATAIN") +">LPTl: "

1000 SHELL ENVIRON$("SORT.DAT") 'data is sorted 1010 FOR I

=

1 TO PARMS

1020 ENVIRON TABLE$(I) Irestore parameters 1030 NEXT I

Note: See also "ENVIRON Statement" and

"SHELL Command." Also "SET Command" in Disk Operating System Reference and "EXEC Function Call" in Disk Operating System Technical Reference.

EOF

Documents relatifs