
Until event = #PB_Event_CloseWindowThe window now contains three gadgets a TextGadget(), a StringGadget(), and a ButtonGadget(), positioned accordingly, and assigned identifiers of 1, 2 and 3 respectively.

#PB_Window_SizeGadget | #PB_Window_ScreenCentered The only event that is processed is the #PB_Event_CloseWindow event, which as you can see, breaks the loop, and essentially ends the program:Ĭode: Select all wFlags = #PB_Window_MaximizeGadget | #PB_Window_MinimizeGadget | In the above skeleton example, the loop simply waits for events, but does not process them in any way. This process continues until the #PB_Event_CloseWindow event is received, and the program terminates.

Then the loop resumes, and pauses again at the WaitWindowEvent() function to await the next event. The WaitWindowEvent() function actually pauses program execution until it receives an event, at which time the event is passed into the loop to be processed. It should be noted that the event loop is not running in a mad frenzy, like a normal endless loop. This is known as an event-driven paradigm, and is the architecture that PureBasic is built upon.
Purebasic tutorial code#
The ultimate purpose is to listen for events that the operating system passes to the program, using the WaitWindowEvent() function, and to process those received events by executing any relevant code associated with the said event. Although the example uses a Repeat-Until loop, any type of loop could be used in its place. The second part is known as the event loop, and is the backbone of any window-based PureBasic program. In order to be referenced later, PureBasic also assigns the window an identifier of 0 - the first parameter.

The first part builds the interface, and simply instantiates a 300-pixel wide by 200-pixel high window at position 100, 100 on the screen, and gives it a title of My Window. Until event = #PB_Event_CloseWindowThere are two parts to this code.
