Program Entry Point
All ViviFire programs must contain a minimum of one module with the file extension .vfire
.
If there are two or more such modules, one must start with Program
and a name.
But if there is only one such module, Program
is optional.
This module is where your program starts to run.
If you supply Program
, the name of the program can be the same as one procedure in the module.
When you write =
before the name, that procedure becomes where the program starts to run.
But if =
is not given, control starts at the top of the module
(the same as a module without Program
).
A procedure lets you easily get arguments from the command line, and/or return an error code to the operating system.
But if these are not necessary in your program, you can select not to use a procedure.
There are alternatives you can use.
For example, Exit Program
can return an error code.
Declaration of the procedure
There are four different mixtures of parameters and return types. It can have one parameter or none, and it can return a value or not.
- The easiest procedure is one that does not have parameters and does not return a value.
Program = NotMuch Sub NotMuch MessageBox "Start of program" MessageBox "End of program" End Sub
- The procedure can return a value of the type
Int32
. The operating system uses this value as the error code for your program. Other programs can read this value.Program = ErrorOnly Sub ErrorOnly As Int32 MessageBox "Start of program" ErrorOnly = %EXIT_SUCCESS MessageBox "End of program with error code " & ErrorOnly & "." End Sub
- The procedure can also have one parameter that is an array of
String
. Each item in the array is one of the command-line arguments given to run your program. You can select what to do with different arguments.Program = ArgsAndError Sub ArgsAndError(args() As String) As Int32 MessageBox "Start of program" For Each arg In args Exit When MessageBox arg & " arg" When DONE ArgsAndError = %EXIT_SUCCESS When NONE ArgsAndError = %EXIT_FAILURE MessageBox "No args!" End For MessageBox "End of program with error code " & ArgsAndError & "." End Sub
- The procedure can also examine the given arguments but not return an error code, as follows.
Program = ArgsOnly Sub ArgsOnly(args() As String) MessageBox "Start of program" For Each arg In args Exit When MessageBox arg & " arg" When NONE MessageBox "No args!" End For MessageBox "End of program" End Sub