calledby(
DATABASE
,
PROCEDURE
)

The calledby( function returns true if this function is in code called by the specified database, the specified procedure, or both.


Parameters

This function has two parameters:

database – database to check for. If this parameter is empty ("") or ommitted, then any database will match.

procedure – procedure to check for. If this parameter is empty (""), then any procedure will match (allowing you to check for any procedure in a specific dataabase).


Description

This function checks to see if the current code is running as a subroutine of a specific datbase and/or procedure. For example, suppose you want to check if the current code is initializing a database.

if calledby(".Initialize")
    ... do something special only when initializing
endif

In the example above, the calledby( function will return true in any subroutine that has been called by .Initialize. (It will also return true for code in the .Initialize procedure itself.

If you need to be more specific, the calledby( function can narrow the check to a procedure in a specific database. In this example, the extra code will only run if it has been called by the .Initialize procedure in this database. It won’t be called if some other database is being initialized.

if calledby(info("proceduredatabase"),".Initialize")
    ... do something special only when initializing THIS database
endif

If the database is specified but the procedure is left blank, the function will return true if it has been called by any procedure in the specified database.

if calledby("Zork","")
    returnerror "We don't like zork"
endif

Probably a more common use for this would be to check if the code is being called from another database. Perhaps for security reasons you don’t want to allow that.

if calledby(info("proceduredatabase"),"")=false()
    returnerror "Can't call this from other databases"
endif

See Also


History

VersionStatusNotes
10.2NewNew in this version.