From the course: Migrating COBOL Apps

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Dynamic calls to subprograms

Dynamic calls to subprograms - COBOL Tutorial

From the course: Migrating COBOL Apps

Start my 1-month free trial

Dynamic calls to subprograms

- [Instructor] While sub program calls are normally made using hard-coded sub program names. In Cobalt, we can dynamically call code modules using the call statement. Let's take a look at how we do this in a small program called planets dot cob. Nano minus l planets dot cob. In line five, we have a working storage variable called planets which we read in with an accept statement at line 11. Then we use this at line 13 to call a sub program, looping around until we enter End. Let's have a look at the Mercury sub program. Nano minus l mercury dot cob. And this is very simple, the program is called Mercury and it just displays a message that Mercury is hot. Let's compile and run this. The main planets code and the various planets sub programs are in your exercise folders. There's code for Venus, Earth and Mars, in addition to Mercury. Cobc minus x and the main program planets dot cob. And we'll include mercury dot…

Contents