SUBROUTINE: initial statement of a subroutine subprogram
-
A subroutine subprogram is invoked in
- a CALL
statement
- in the ALARM() function
-
in a callback from many HicEst
functions.
-
Unlike the FUNCTION
procedure a subroutine does not return a particular value. It may return variable values only via the parameter list.
-
The following are examples of subroutines and how to call them. The procedures differ in the scope of variables, either local or global
-
⇒ Programming (procedures)
-
this by the way is a complete HicEst script
REAL :: var1=111.111, var2=222.222
CHARACTER
MENU="hello world; good morning", selected_text*20
CALL SUB_no_USE_no_ARG
CALL SUB_with_USE
CALL SUB_with_ARG( var1, var2^2, "hello world") ! parameter list with 3 actual arguments
CALL SUB_with_ARG_and_USE( var1+var2 )
ALARM(2.3, 5) ! calls F5 in 2.3 sec
POP(Menu=MENU, SelTxt=selected_text) ! calls MENU from popup menu
END
SUBROUTINE SUB_no_USE_no_ARG
! definitions are global
WRITE(Messagebox, Name) var1, var2, var3
END ! message box output: var1=111.111; var2=222.222; var3=0;
SUBROUTINE SUB_with_USE
USE
: var2 ! use a global variable
! with USE definitions are local
var3 = 333.333 ! this is a local variable
WRITE(Messagebox, Name) var1, var2, var3
END ! message box output: var1=0; var2=222.222; var3=333.333;
SUBROUTINE SUB_with_ARG(dummy1, dummy2, dummy3) ! 3 dummy arguments
CHARACTER dummy3 ! string dummies must be defined
! with arguments definitions are local
WRITE(Messagebox, Name) dummy1, dummy2, dummy3
END ! message box output: var1=111.111; dummy2=49382.61728; dummy3=hello world;
SUBROUTINE SUB_with_ARG_and_USE(dummy1)
USE : var2
USE SUB_with_USE : var3
WRITE(Messagebox, Name) dummy1, var2, var3
END ! message box output: dummy1=333.333; var2=222.222; var3=333.333;
SUBROUTINE F5 ! alarm subroutine, also on toolbar
time = TIME()/60/60/24 ! fractional day
WRITE(Messagebox, Format="UHH:mm:SS") time
END ! message box output: 16:58:34
SUBROUTINE MENU ! example of a callback routine
WRITE(Messagebox, Name) $$, selected_text
END ! message box output: $$=2; selected_text=good morning;
©2000-2010 Georg Petrich, HicEst Instant Prototype Computing. All rights reserved. Impressum |