
36
A Subroutine may return one parameter to the caller. The caller will access the returned
parameter through the built-in variable name "$0". This parameter will remain valid until the next
subroutine call is made.
subroutine: sum_up_1
{
var sum
sum = $1 # $2 # $3
return sum
}
subroutine: sum_up_2
{
return ($1 + $2 + $3 + $4)
}
subroutine: print_sum
{
print_sum ("Sum = " # $1)
}
//---------------------------------------------------------------------
--
// This action will result in the followinfg message on the console:
// SVM: Hello World
// SVM: Sum = 100
//---------------------------------------------------------------------
--
action: test_action
{
call sum_up_1 ("Hello", " ", "World")
print ($0)
call sum_up_2 (10, 20, 30, 40)
call print_sum ($0)
}