Using files defined as EXTERNAL with Visual COBOL
Many Visual COBOL projects may use the same EXTERNAL data files, this usually would require setting an environment variable for each file within an Application.config.
How can these file mappings be achieved without the use of an Application.config?
Setting EXTERNAL file variables within a Visual COBOL project
In the example below, an entry needs to be added to an Application.config file (Environment) in order for the physical file assignment for the SELECT clause to be resolved:
If EXTERNAL does not appear in the SELECT statement, the program must be compiled with the directive ASSIGN(EXTERNAL):
To add an application configuration file, right-click your project in the Solution Explorer:
Click Add > New Item
- Select Application Configuration File
- Specify a filename in the Name field (or leave as is)
- Click OK
Edit the Application.config; add the variable name and file name:
Setting EXTERNAL file variables within the environment
The environment variable can be set in the environment before launching Visual COBOL. An entry in the Application.config would not be necessary.
When Visual COBOL is started, it will inherit the settings from the environment, a batch file or script can be used to set up various environment variables and file mappings etc. before launching Visual COBOL.
The most straight-forward way to set the variables externally is to start a Visual COBOL command prompt, then set the file mapping and start Visual COBOL:
Creating a script to set COBCPY and launch Visual Studio
REM * Set File mappings externally then start Visual Studio
REM * Call createenv.bat to set the COBOL environment
CALL "C:\Program Files (x86)\Micro Focus\Visual COBOL\createenv.bat"
REM * Add file mappings
REM * Start Visual Studio ( use MFDEVENVnn - where nn represents version of Visual Studio)
REM * Alternatively start Visual Studio using DEVENV ("C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\DEVENV:)
REM * The example above uses Visual Studio 2015.
REM * Close the command prompt