Skip to main content

Calling Another Routine

Before starting the next exercise, you need to know the syntax for calling a subroutine of one module from another. So far, you've called Basic subroutines from the Terminal using ObjectScript syntax: do main^myBASdatent(), using “^” between the subroutine and the routine names. To call subroutines—either Basic or ObjectScript—from Basic, use the Basic syntax: main@myBASdatent(), using “@” between the subroutine and the routine names.

When passing arguments to subroutines, Basic and ObjectScript use different syntaxes:

Passing Arguments
Calling Language Called Language Syntax Example
ObjectScript ObjectScript The default is pass-by-value. The calling code specifies which arguments are pass-by-reference by preceding each argument with a period (.). do sub^rou(a, .b)
ObjectScript Basic The default is pass-by-value. The calling code specifies which arguments are pass-by-reference by preceding each argument with a period (.). The signature of the called method may use the ByVal or ByRef argument qualifiers, but they do not have any effect. do sub^rou(a, .b)
Basic ObjectScript The default is pass-by-reference. The calling code specifies which arguments are pass-by-value by preceding each argument with ByVal. The calling code can also use ByRef for clarity. sub@rou(ByVal a, b)
Basic Basic This call relies on the signature of the called method. The calling code can override the signature using ByRef or ByVal. sub@rou(a,b)
FeedbackOpens in a new tab