Skip to main content

Problem:

How to setup environment variable to point to location of file from within a program.

Resolution:

Search in the  net express 4.0 help  for EMBEDDED ENVIRONMENT VARIABLES and  will find the following :

Embedded Environment Variables

You can include an environment variable in the name of a file you want to open. It should have been previously given a value using the operating system SET command. The file specification is of the form:

$env-name\\filename.ext

Example

$test\\app.dat

where you have issued the command:

set test=c:\\appdir;d:\\appdir\\appsub;

env-name will only be recognized as an environment variable if it is enclosed within dollar ($) and backslash (\\) characters; thus if you simply specify an environment variable by itself it will not be expanded.

The environment variable env-name can contain a list of one or more paths, separated by a semicolon (;). The open mode of the file determines the path to which the environment variable is expanded. If an existing file is being opened, using OPEN INPUT, OPEN I-O, OPEN EXTEND or the CBL_OPEN_FILE byte stream routine, the environment variable is expanded to the first path named in the list on which the file is found. If a new file is being created, using OPEN OUTPUT, OPEN I-O, OPEN EXTEND, or the CBL_CREATE_FILE byte stream routine, the environment variable is expanded to the first path named.

Old KB# 7149