DCL Subroutines


Jeff,

Is there any limit to the number of times that a subroutine in a command procedure can be called? I'll be crushed if there is, because I much prefer them to wretched GOTOs. I also heard that they're fast, too.

In answer to your question "Is there any limit to the number of times that a subroutine in a command procedure can be called?" the answer is :

There is no limit.

However DCL is not reentrant so a procedure cannot call itself, or call another procedure that eventually calls itself again. Also for any given level of DCL command procedures, GOSUB calls can only go 16 levels deep in calls.

Hope this helps

Jeff

PS. I am an old FORTRAN programmer, competent in my skills as such, and I'm not afraid to use GOTOs.

Addendum
2-JUN-1999

Thanks to Brian Schenkenberger of TMESIS for pointing out that the proper answer is a bit more involved than the above response.

In DCL there are two types of SUBROUTINES. There is the GOSUB/RETURN version and the CALL/SUBROUTINE/ENDSUBROUTINE version.

In my answer above I was only addressing the GOSUB/RETURN version, where you are allowed 16 levels of subroutine calls for each of the possible 32 DCL command procedure levels. This form is not reentrant since the context of local DCL symbols is valid only for the level of the command procedure, and all GOSUB levels use the same scope of local and global DCL symbols.

As Brian pointed out to me, the other method of DCL subroutines, ie: the CALL/SUBROUTINE/ENDSUBROUTINE method, essentially allows the user to encapsulate a multiple file/command procedure into one file/command procedure. In other words rather than having multiple command procedures calling one another using the @ (at-sign) they could invoke the procedure using the DCL CALL command which then processes the corresponding SUBROUTINE/ENDSUBROUTINE section as if it were a new level of DCL command procedures, even though the code is embedded in the original file/command procedure.

In this case, you are limited by DCL's level of command procedures, ie: 32 levels. Also, since each level of DCL command procedures allows a local DCL symbol table, you can say that this form of DCL subroutine calls is indeed, reentrant, as long as you do not exceed the total procedure level of 32.


Send me your question. 


 

My Home Page | VMS Home

DCL | Utilities | Management | Tips

FORTRAN | Pascal

eMail Questions

Quiz?