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:
open(1,u:i,"filename@server")
We recommend using an environment variable assignment (or logical on OpenVMS), such as this:
open(1,u:i,"env_variable:filename")
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
DAT=@server_name
On OpenVMS, this will point to the user’s home directory.
- To point to the SRV environment variable, as defined by xfServer, use
DAT=SRV:@server_name
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:
open(1,u:i,"DAT:cusmas")
The DAT:cusmas data request might be translated as shown in figure 1 for a Windows client connected to a Unix server.
|