Repository navigation
Setenviron
Home › Operating System Functions › SetEnviron
Sets an environment variable from "NAME=value" text; returns 0 on success.
Declare Function SetEnviron ( ByRef varexpression As String ) As Longvarexpression
Modifies system environment variables. There are several variables available for editing other than the default ones on your system. An example of this would be fbgfx, where you can choose the form of graphics driver the FreeBASIC graphics library will use.
Return zero (0) if successful, non-zero otherwise.
result = SetEnviron( varexpression )
- In Linux and macOS,
varexpressionmust be permanent (a literal, a variable declared in the main code or a static variable declared in a procedure), because the system does not memorize the string but only a pointer to its data characters.
- In QB,
SetEnvironwas calledEnviron.
'e.g. to set the system variable "path" to "c:":
Shell "set path" 'shows the value of path
SetEnviron "path=c:"
Shell "set path" 'shows the new value of path'' WINDOWS ONLY EXAMPLE! - We just set the graphics method to use
'' GDI rather than DirectX (or Direct2D added on new systems).
'' You may note a difference in FPS.
SetEnviron("fbgfx=GDI")
'' Desktop width/height
Dim As Long ScrW, ScrH, BPP
ScreenInfo ScrW, ScrH, BPP
'' Create a screen at the half width/height of your monitor.
'' Normally this would be slow, but GDI is fairly fast for this kind
'' of thing.
ScreenRes ScrW/2, ScrH/2, BPP
'' Start our timer/
Dim As Double T = Timer
'' Lock our page
ScreenLock
Do
'' Print time since last frame
Locate 1, 1
Print "FPS: " & 1 / ( Timer - T )
T = Timer
'' Flip our screen
ScreenUnlock
ScreenLock
'' Commit a graphical change to our screen.
Cls
Loop Until Len(Inkey)
'' unlock our page.
ScreenUnlockCategory: Operating System Functions
Kind: function
Reproduced from the FreeBASIC Wiki Manual under the GNU Free Documentation License 1.3 — with no Invariant Sections, no Front-Cover Texts and no Back-Cover Texts. Copyright © the FreeBASIC project and wiki contributors. See License.
tiko-lang · Home · Feature Index · Keyword Index · License
FreeBASIC manual pages reproduced under the GNU FDL 1.3.
- Generics
- Interfaces
- For Each
- Iterators
- Tuples
- Array Results
- Defer
- Lambdas
- Block Strings
- Partial Types
- String Slices
- Embed
- Typed Variadics
- C Header Import
- Foreign Library Linking
- UString
- Fixed-Width Types
- Nullptr
- String Library
- Format
- Array
- Map
- Set
- LinkedList
- OrderedMap
- OrderedSet
- Sorting
- Optional
- Result
- Smart Pointers
- Date and Time (Chrono)
- Filesystem
- File Streams
- Config (INI and TOML)
- Codec
- Hash
- UUID
- OS
- Process
- Net
- HTTP and TLS
- Math Library
- Finance
- Logging
- Terminal TUI Library
- PsControls
- tkControls
- sys/win
- Goroutines and Channels
- LLVM Backend
- tiko build
- TIKO_COMPILER
- Variable Declarations
- Standard Data Types
- User Defined Types
- Procedures
- Operators
- Control Flow Statements
- Converting Data Types
- Array Functions
- String Functions
- Mathematical Functions
- Bit Manipulation
- Date and Time Functions
- File I/O Functions
- Console Functions
- User Input (Runtime Library)
- User Input Functions (Graphics Library)
- Screen Functions
- 2D Drawing Functions
- Graphics Library Reference
- Graphics Keyword List
- Memory Functions
- Threading Support Functions
- Error Handling Functions
- Operating System Functions
- Preprocessor
- Intrinsic Defines
- Miscellaneous Keywords
- Modularizing