GUI ScreenIO for Windows

Static and Dynamic Subroutine CALLs

Keep in mind as you read this, that some compilers let you set options that will override the calling mechanisms shown below. Therefore, even if your program is coded to call a program statically, the compiler can convert it to the dynamic form of CALL if you set (or don't set) the correct compiler options.

This is something to beware of, because it can cause problems for you if you don't understand the issues.  

Static CALLs

In COBOL, you normally call a subroutine like this:

     CALL 'A' USING arguments

The static form of the CALL statement specifies the name of the subroutine as a literal; e.g., it is in quotes.

This is the static form of a subroutine call.  The compiler generates object code for this which will cause the linker to copy the object module a.obj into your executable when it is linked.

So, if you modify "A" and recompile it, you must also relink all of the executables that call "A", because the each of the executables contains its own copy of "A". 

Good Things About Static CALLs

Bad Things About Static CALLs

Dynamic CALLs

In COBOL, the dynamic form of a subroutine call is coded like this:



The dynamic form of the CALL statement specifies the name of the subroutine using a variable; the variable contains the name of the subroutine to be invoked.

The difference is that the name of the subroutine is found in the variable SUBROUTINE-A.  The compiled code will cause the operating system to load the subroutine when it is required instead of incorporating it into the executable..

Note that you can also load a module dynamically by including it in a DLL and then linking it using the import library for that DLL!

Good Things About Dynamic CALLs

Bad Things About Dynamic CALLs

Which is better, Static or Dynamic CALLs? 

The answer is, it depends.

You really need to consider the pros and cons and how they affect your own application.  For what it's worth, though, we favor using a minimum of executable modules because it reduces headaches with mismatched or lost pieces of an application.   

Dynamic CALLs via an Import Library

It's possible to create a DLL that contains many subroutines, but which is accessed as though the subroutines are statically linked.  This is a very neat trick that uses the best features of static and dynamic linking. 

Related topics:

2000-2019 Norcom, all rights reserved 


Send feedback to Norcom