CALL Examples


Example 1:

 

  

CALL

JULNDATE

 

Initiates the subroutine designated by the Program Execution Label JULNDATE. If the subroutine ends with a RETURN, execution resumes with the instruction immediately following the CALL.

 

Example 2:

 

  

CALL

GREGDATE IF (ANS = "Y")

 

Initiates the subroutine designated by the Program Execution Label GREGDATE only if ANS is equal to a "Y". The preceding RETURN example still applies.

 

Example 3:

 

  

CALL

EVENTCHK IF EVENT

 

Transfers control to the subroutine EVENTCHK if any of the various graphical objects have been activated by the mouse. This function code is only available with PLBCMP in a GUI environment.

 

Example 4:

 

DATE

DIM

8

YY

FORM

2

MM

FORM

2

DD

FORM

2

  

...

 

  

CALL

JULNDATE USING DATE,YY,MM,DD

  

...

 

#JULIAN

DIM

^

#YEAR

FORM

^

#MONTH

FORM

^

#DAY

FORM

^

JULNDATE

LROUTINE

#JULIAN,#YEAR,#MONTH,#DAY

  

...

 

  

RETURN

 

 

This CALL initiates the LROUTINE JULNDATE using four parameters. DATE is a DIM field and YY, MM and DD are all FORM fields. The corresponding LROUTINE instruction specifies four parameters also and they must match the type of the parameters of the CALL instruction. During the execution of the subroutine, reference to any of the variables on the LROUTINE list actually refer to the corresponding variables on the CALL list. This example also shows the usage of local labels that start with a '#' character.

 

Example 5:

 

DATE

DIM

8

YY

FORM

2

MM

FORM

2

DD

FORM

2

  

...

 

  

CALLS

"DATES;JULNDATE" USING DATE,YEAR,MONTH,DAY

  

...

 

#JULIAN

DIM

^

#YEAR

FORM

^

#MONTH

FORM

^

#DAY

FORM

^

JULNDATE

ROUTINE

#JULIAN,#YEAR,#MONTH,#DAY

  

...

 

  

RETURN

 

 

This CALLS the JULNDATE subroutine located in the DATES.PLC module. DATES.PLC is loaded automatically if not already loaded.

 

Example 6:

 

DATE

DIM

8

YY

FORM

2

MM

FORM

2

DD

FORM

2

  

...

 

  

CALLS

"DATES;JULNDATE" GIVING DATE USING YEAR,MONTH,DAY

  

...

 

#JULIAN

DIM

8

#YEAR

FORM

^

#MONTH

FORM

^

#DAY

FORM

^

JULNDATE

ROUTINE

#YEAR,#MONTH,#DAY

  

...

 

  

RETURN

USING #JULIAN

 

This CALLS the JULNDATE subroutine located in the DATES.PLC module and shows the implementation of the GIVING keyword to retrieve the converted DATE. DATES.PLC is loaded automatically if not already loaded.

 

Example 7:

 

DATE

DIM

8

YY

FORM

2

MM

FORM

2

DD

FORM

2

  

...

 

  

CALLS

"1|DATES;JULNDATE" USING DATE,YEAR,MONTH,DAY

  

CALLS

"2|DATES;JULNDATE" USING DATE,YEAR,MONTH,DAY

  

...

 

#JULIAN

DIM

^

#YEAR

FORM

^

#MONTH

FORM

^

#DAY

FORM

^

JULNDATE

ROUTINE

#JULIAN,#YEAR,#MONTH,#DAY

  

...

 

  

RETURN

 

 

These CALLS instructions each create a unique instance of the DATES LOADMOD with their own copies of the variables defined in the LOADMOD (#JULIAN, #YEAR, #MONTH, and #DAY).

 



PL/B Language Reference CALC Examples CHAIN Example