|
From: David E. <de...@us...> - 2005-08-06 18:15:04
|
John R. Culleton wrote: > I assume that the COBOL code for creating and calling > subprograms is pretty standard. On UN*X the first function to be executed (main-program) is called an entry point. This can be set, but the default is called 'main'. With COBOL there is no easy way to determine which is a main-program and which is a sub-program. Beginning with version 0.63, TC has several options giving the user to more flexibility. The following options can be set in the compile time resource file, 'htcobolrc', or on the command line. # Specify the default main program (entry point) action # # auto - Use the first encountered 'STOP RUN' statement, # and if found, generate a program entry point. # # first - Use the first encountered 'PROGRAM-ID' statement, # and if found, generate a program entry point. # # none - Do not generate any program entry point. # PGM_ENTRY_POINT_AUTO #PGM_ENTRY_POINT_NONE #PGM_ENTRY_POINT_FIRST The 'PGM_ENTRY_POINT_AUTO' option (-M auto) will try to guess at which is the main program. The 'PGM_ENTRY_POINT_FIRST' option (-M first) will use the first encountered 'PROGRAM-ID' statement as the main program. With the first/auto options, TC will generate a 'main' entry point and call the main program. With the 'PGM_ENTRY_POINT_NONE' option (-M none) a 'main' entry point is not generated. If for some reason all else fails, the '-e programid' command line option can be used to manually set the main program, if a 'PROGRAM-ID' statement is found with that entry. In this case TC will set 'programid' as the main program, and generate a 'main' entry point. This approach is more complex but more flexible, in my view. > The tricky part for me is the compile options. > In OpenCobol for example the main program has to be compiled > with a special parameter indicating it is a main program. The problem with that approach is that if you have a sequence of COBOL programs in one source, which is the main and which are the sub-programs. > The subprogram is compiled to a linkable object. > Then both are compiled together to come up with an executable. > > I presume something similar is going one with TC but I can't > guess what. > > 1. Can/should the main program and sub program sources be resident in > the same directory? They can reside in different directories, but generally it is the same directory. > 2. What does the command line for compiling main program > foo.cbl look like? > > 3. What does the command line for compiling subprogram bar.cbl look like? > > 4. What does the linking command (if any) look like? Example: (with PGM_ENTRY_POINT_AUTO) htcobol -c foo.cbl htcobol -c bar-1.cbl ... htcobol -c bar-n.cbl gcc -o prog1 foo.o bar-1.o ... bar-n.o -lhtcobol -ldb ... Example: (with PGM_ENTRY_POINT_NONE) htcobol -c -M first foo.cbl htcobol -c bar-1.cbl ... htcobol -c bar-n.cbl gcc -o prog1 foo.o bar-1.o ... bar-n.o -lhtcobol -ldb ... > Thanks as always. The existing manuals don't address this issue > AFAIK. There are several examples in the 'test.code' directories. |