PBMAIN function

Purpose | PBMAIN is a user-defined function called by Windows to begin running an executable application. Every PowerBASIC executable (EXE) must contain either a PBMAIN or a WINMAIN function.
Syntax | FUNCTION PBMAIN [()] [AS LONG]

Remarks

Either a PBMAIN or WINMAIN function is required in every PowerBASIC application (.EXE). If you use PBMAIN, no parameters are passed, and you cannot directly obtain the instance handle of your application or the pointer to any command-line parameters.

However, you can use COMMAND$ to get the command-line passed to your program, and the GetModuleHandle API function to get the application instance handle.

Return | The return value of PBMAIN has an effective range of 0 to 255. Batch files may act on the result through the IF [NOT] ERRORLEVEL batch command.
Restrictions | DLLs created with PowerBASIC should contain a DLLMAIN, LIBMAIN, or PBLIBMAIN function instead of PBMAIN/WINMAIN.
See also | COMMAND$, DLLMAIN, LIBMAIN, PBLIBMAIN, WINMAIN

Example

#COMPILE EXE

FUNCTION PBMAIN

MSGBOX "This is my program!"

'Return an error level of 15

FUNCTION = 15 ' or you can use PBMAIN = 15

END FUNCTION