Skip to Content

Can I use directory paths in CALL names?

Estimated Reading Time: 2 Minutes
Question:

My application source contains files that have the same name but are in different directories, e.g. dir1/progA.cbl, dir2/progA.cbl. I rely on the ability to specify paths in the CALL names in order to differentiate the programs, e.g. CALL "dir1/PROGA". 

Can I do this with isCOBOL?
If so, then how?

Answer:

In order to specify paths in CALL names, you need to set iscobol.code_prefix to the list of directories where your COBOL programs are located. The directory paths must be separated by the current operating system's line feed character or path separator (\n). For example,

iscobol.code_prefix=c:myapplib1classes c:myapplib2classes 

For a simpler example, if a program named TESTPROG does CALL "dir1/progA" and PROGA.class is in a subdirectory named dir1, you could run TESTPROG with:

java -Discobol.code_prefix=. TESTPROG 

To search for a program, the isCOBOL runtime framework first looks in the JAR files and directories listed in the class path. It then looks in the directories listed in iscobol.code_prefix.

Relative paths specified in CALL names are treated as relative to the directories listed in iscobol.code_prefix. The isCOBOL runtime framework appends the path from the CALL name to each value in iscobol.code_prefix to find the program

When iscobol.code_prefix is set to '.' the isCOBOL runtime framework searches in the current working directory and treats paths in CALL names as relative to the current working directory.

If you need to specify absolute paths in CALL names then set iscobol.code_prefix to '/' on Unix or 'c:' on Windows.

Here is some additional information:

The isCOBOL Compiler produces Java classes using the file names as class names. By default, the isCOBOL runtime framework searches for the classes (.class files) in jar files or directories that are listed in the class path. For example, with CALL "PROGA", the isCOBOL framework will attempt to create an instance of a class named PROGA. The Java framework will search for PROGA.class in all of the JAR files and directories that are listed in the class path (i.e. either in the CLASSPATH environment variable or the value specified with the java -cp command line option.)

In this case, CALL "dir1/progA" will fail because "dir1/progA" is not a valid class name. 

However, if you specify iscobol.code_prefix then the isCOBOL runtime framework will use its own class loader and will use the value of iscobol.code_prefix as well as any path information in the CALL name to load the class.
Can I use directory paths in CALL names?

Powered by PHPKB (Knowledge Base Software)