17.07.2013 Views

GWBASIC User's Manual

GWBASIC User's Manual

GWBASIC User's Manual

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

GW-BASIC <strong>User's</strong> Guide<br />

ENVIRON$ Function<br />

Purpose:<br />

To allow the user to retrieve the specified environment string from the environment table.<br />

Syntax:<br />

v$=ENVIRON$(parmid)<br />

v$=ENVIRON$(nthparm)<br />

Comments:<br />

parmid is a valid string expression containing the parameter to search for.<br />

nthparm is an integer expression in the range of 1 to 255.<br />

If a string argument is used, ENVIRON$ returns a string containing the text following parmid=<br />

from the environment string table.<br />

If parmid is not found, then a null string is returned.<br />

If a numeric argument is used, ENVIRON$ returns a string containing the nth parameter from the<br />

environment string table.<br />

If there is no nth parameter, then a null string is returned.<br />

The ENVIRON$ function distinguishes between upper- and lowercase.<br />

Examples:<br />

The following lines:<br />

ENVIRON "PATH=A:\SALES; A:\ACOUNTING; B:\MKT:" 'Create entry<br />

PRINT ENVIRON$("PATH") 'Print entry<br />

will print the following string:<br />

A:\SALES; A:\ACCOUNTING; B:\MKT<br />

The following line will print the first string in the environment:<br />

PRINT ENVIRON$(1)<br />

The following program saves the environment string table in an array so that it can be modified<br />

for a child process. After the child process completes, the environment is restored.<br />

10 DIM ENVTBL$(10)<br />

20 NPARMS= 1<br />

30 WHILE LEN(ENVIRON$(NPARMS))>0<br />

file:///C|/Documents%20and%20Settings/Lorenzo/Desktop/GW%20Basic/ENVIRONS.html (1 of 2)28/03/2004 21.29.24

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!