Prev Page Next Page
Subs
Previous Top Next

Subs declarations start with Sub SubName (Parameters) and end with "End Sub".

If there are no parameters for the sub, then write "Sub SubName" without the parentheses. Because parameter names are local names  if a global name is used as a parameter name in a Sub definition then an error occurs.

There are no functions in B4Script but instead every Sub can return a value with the keyword "Return".

All parameters are passed by value. That is if an assignment is made to a parameter variable it only alters the value of that local variable and not that of the original variable.

"EndSub" is also accepted in place of "End Sub"


Calling a sub

To call a sub, write its name followed by an opening parenthesis and the parameters separated by "," followed by a closing parenthesis. If there are no parameters then do not write any parentheses.
Example:

Sub ShowMean
            Msgbox("The mean of 20 and 30 is " & crlf &  Mean(20,30))
End Sub

Sub Mean (a, b)
            Return (a+b)/2
End Sub

Result: A message box that displays 25.
  
Prev Page Next Page
Converted from CHM to HTML with chm2web Pro 2.85 (unicode)