Why use environment variables with xfServer?
Although you can hard-code server specifications in your program, to keep your xfServer system portable and manageable you must define environment variables and use them in your application’s filename specifications. If you hard-code the entire file specification in your program, and those files move, or if your user doesn’t set up the system exactly as you expect, you will need to change the file specifications and recompile your program.
For example, instead of using a hard-coded method such as this for file access:
We recommend using an environment variable assignment (or logical on OpenVMS), such as this:
The environment variable replaces the server name in your actual code.
The following examples show two ways that you might define the DAT environment variable:
- On Windows and UNIX xfServer, to point to the default directory, as defined by RSFILPATH set on the server, use
On OpenVMS, this will point to the user’s home directory. (See RSFILPATH for more information about this environment variable.)
- To point to the SRV environment variable, as defined by xfServer, use
In this case, all users go to the same directory. You must also define the SRV environment variable on the xfServer machine. For instructions on defining environment variables for the xfServer service, refer to the following operating system-specific information:
- Windows, see Defining environment variables for xfServer services
- UNIX, see Defining environment variables for xfServer processes
- OpenVMS, see Defining logical names for xfServer processes
Let’s say that you’ve defined DAT=SRV:@server, and your application has the statement:
The DAT:cusmas data request might be translated as shown in figure 1 for a Windows client connected to a UNIX server.