Wiki source for KeyPgSetenviron

Show raw source

{{fbdoc item="title" value="SETENVIRON"}}----
Sets a system environment variable

{{fbdoc item="syntax"}}##
[[KeyPgDeclare|declare]] [[KeyPgFunction|function]] **Setenviron** ( [[KeyPgByref|byref]] //varexpression// [[KeyPgAs|as]] [[KeyPgString|string]] ) [[KeyPgAs|as]] [[KeyPgLong|long]]
{{fbdoc item="usage"}}##
//result// = **Setenviron**( //varexpression// )
{{fbdoc item="param"}}
Name and setting of an environment variable in the following (or equivalent) form: varname=varstring.
(varname being the name of the environment variable, and varstring being its text value to set)

{{fbdoc item="ret"}}
Return zero (0) if successful, non-zero otherwise.

{{fbdoc item="desc"}}
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.

{{fbdoc item="ex"}}
{{fbdoc item="filename" value="examples/manual/system/setenviron.bas"}}%%(freebasic)
'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

{{fbdoc item="filename" value="examples/manual/system/setenviron2.bas"}}%%(freebasic)
'' 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.

'' Desktop width/height
Dim As Integer 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

'' Print time since last frame
Locate 1, 1
Print "FPS: " & 1 / ( Timer - T )
T = Timer

'' Flip our screen
'' Commit a graphical change to our screen.

Loop Until Len(Inkey)

'' unlock our page.

{{fbdoc item="diff"}}
- In QB, ##**Setenviron**## was called ##**Environ**##.

{{fbdoc item="see"}}
- ##[[KeyPgEnviron|Environ]]##
- ##[[KeyPgShell|Shell]]##

{{fbdoc item="back" value="CatPgOpsys|Operating System Functions"}}
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki phatcode