HTBasic Help
×
Menu
Index

Context

 
A context is a program unit with its own environment, including local variables, which can be called recursively by other contexts, and can pass arguments, either by reference or by value. There are four types of contexts: 1) main context, 2) subprogram context, 3) user defined function, 4) CSUB context.
The main context begins with the first line of the program and ends with the program line containing the "END" statement. The main context is started by a RUN command.
A subprogram context begins with a SUB statement and ends with a SUBEND statement. It is called with a CALL statement and terminates with a SUBEND or SUBEXIT statement. Arguments can be passed to a subprogram.
A user defined function begins with a DEF statement and ends with an FNEND statement. It is called from within a numeric or string expression by referencing its name. It terminates and returns a value with a RETURN statement. The expression then continues to evaluate, using the value returned in place of the function reference. Arguments can be passed to a function.
A CSUB is a compiled subprogram created with special tools outside of HTBasic. It is loaded into memory with the LOADSUB statement and removed from memory with the DELSUB statement. It is called with a CALL statement.