PureBasic 101 - Scopes

Опубликовано: 02 Март 2026
на канале: Pure Programming
1,522
57

Learn the fundamentals of PureBasic. In this PureBasic 101 series, I cover the language, the IDE, the tools and some programming tips and techniques.

In this episode, I explain variable scope : default (Define), Global, Shared, Protected, Static and Threaded.

Default (0:00:23) : the default scope is accessible from the main code but neither from procedures nor modules
Global (0:01:50) : global variables are accessibles from everywhere except modules (when defined outside of them)
Shared (0:08:36) : shared variables are a way to use a non-global (default) variable defined in the main code in a procedure.
Protected (0:11:21) : protected variables are local to a procedure. They are not accessible from outside the procedure and they can have the same name as a global variable.
Static (0:13:58) : static variables are local procedure variables that keep their value between calls.

[ADVANCED]
Threaded (0:18:24) : threaded variables are local to each thread but act as global variables within the thread. They are stored in the TLS (Thread Local Storage)

The file for this episode is available at http://bit.ly/39IDRin

Download PureBasic at http://www.purebasic.com/pp

Support the channel with some Merchandising
EU : shop.spreadshirt.net/pure-programming
US : shop.spreadshirt.com/pure-programming