Title: Can the file system (iscobol.file.index) be set programmatically?

Question:

Can I set the iscobol.file.index or iscobol.file.index.FileName variables inside my COBOL program?
My application reads a file which has information about which file system to use for each data file.
Some data files are Jisam. Others are in Oracle. My application allows the user to choose which files to create in the database. So I need to set this programmatically.
How do I do that in isCOBOL?

Answer:

You can set both "file.index" and "file.index." using the SET ENVIRONMENT.
Note that you don't use the 'iscobol.' at the beginning of the property name when you set properties with SET ENVIRONMENT.

For instance, if your users want file1 to be a database, you would set this in your properties file:

   iscobol.file.index=jisam
and in your program set that file's file handler dynamically:
   set environment "file.index.file1" to "easydb"

Another way to associate file handlers to your files is by using the CLASS clause in FILE-CONTROL.
Setting the file to a specific class overrides external settings in your enviornment.

In versions 2022R2 and later, you can also set or change the CLASS clause for each file "on the fly" by using a hook program.
Write a program to set file.class to whatever file handler you want, and set that program as a hook using:

   iscobol.file.index.open_hook=[hook_program_name]
There is a sample of this in the installed samples folder, under extend-and-customize/file-open-hook.
The hook program in the example checks the location of the file and the running environment.
If the file is in the temp folder, the file format is set to Jisam instead of EasyDB.
You can write whatever logic you need to determine the file format of a file just before it is opened.

Authored by: Veryant Support on Wed, Sep 2nd, 2009 at 7:00 PM
This question has been viewed 8939 times so far.
Online URL: http://support.veryant.com/support/phpkb/question.php?ID=90

Powered by PHPKB Knowledge Base Software