From Liberty BASIC Family
Jump to navigation Jump to search
Supported in Just BASIC Supported in Liberty BASIC Not supported in Liberty BASIC 5 Not supported in Run BASIC


Instructs the BASIC interpreter not to open a main window (MAINWIN).




This command is usually used when programming in a GUI environment. If you do not include a NOMAINWIN command, a main window will open along with your program window. This is useful while your program is under development because it allows you to close a program that has stopped working or crashed. If you include NOMAINWIN in a program, you must also use TRAPCLOSE handlers and an END statement for your program and all its windows to close properly.
The main window will only close automatically when your program is running standalone (i.e.; as an .EXE program).
NOMAINWIN is a compiler directive and can only be disabled by commenting it out. There is no way to disable it through an IF..THEN construct.
The main window will be suppressed, if you place a NOMAINWIN statement anywhere in your program listing
If your program has statements to print to the mainwin, those statements will still be executed when your program runs, even if you include a NOMAINWIN. You won't see them because there is no mainwin to print to, but it could slow down the execution of your program. Commenting out those print statements will prevent them from being executed and increase the speed of your program.


' turn the main window off

' open a GUI window
open "My Window" for window as #win

' trap closing the GUI window, which is mandatory
#win "trapclose [quit]"

' wait for user action

' event handler for closing the window

' close the window
close #win

' terminate the program

Useful Procedures

' Place a useful function or sub using this keyword here