Environment variables: Difference between revisions
Content deleted Content added
Adds slope example |
Add SmallBASIC |
||
(8 intermediate revisions by 7 users not shown) | |||
Line 191:
<syntaxhighlight lang="is-basic">ASK machine-option-code var</syntaxhighlight>
==={{header|SmallBASIC}}===
print env("HOME")
print env("PATH")
print env("USER")
</syntaxhighlight>
==={{header|ZX Spectrum Basic}}===
Line 342 ⟶ 349:
=={{header|Emacs Lisp}}==
<syntaxhighlight lang="lisp">(getenv "HOME")</syntaxhighlight>
=={{header|EMal}}==
<syntaxhighlight lang="emal">
fun showVariable = <text variable|writeLine(variable + ": '" + Runtime.get(variable) + "'")
showVariable("SystemDrive")
showVariable("USERNAME")
# we can get the environment variables as a map
Map variables = Runtime.variables()
writeLine(variables["TEMP"])
</syntaxhighlight>
{{Out}}
<pre>
SystemDrive: 'C:'
USERNAME: 'XXXYYY'
C:\Users\xxxyyy\AppData\Local\Temp
</pre>
=={{header|Erlang}}==
Line 409 ⟶ 432:
println( $home )
println( $user )</syntaxhighlight>
=={{header|FutureBasic}}==
<syntaxhighlight lang="futurebasic">
include "NSLog.incl"
NSLog(@"%@",fn NSUserName)
NSLog(@"%@",fn NSFullUserName)
NSLog(@"%@",fn NSHomeDirectory)
NSLog(@"%@",fn NSTemporaryDirectory)
HandleEvents
</syntaxhighlight>
=={{header|Go}}==
Line 550 ⟶ 585:
=={{header|langur}}==
<syntaxhighlight lang="langur">
writeln "
writeln "USER: ", _env["USER"]</syntaxhighlight>▼
▲<syntaxhighlight lang="langur">writeln "HOME: ", _env'HOME
writeln "PATH: ", _env'PATH
writeln "USER: ", _env'USER
</syntaxhighlight>
=={{header|Lasso}}==
Line 891 ⟶ 922:
ExpandEnvStrings $1 "%USERPROFILE%" ; Retrieve the user's profile location and place it in builtin register 1.
ExpandEnvStrings $2 "%USERNAME%" ; Retrieve the user's account name and place it in builtin register 2.</syntaxhighlight>
=={{header|Nu}}==
<syntaxhighlight lang="nu">
$env.HOME
</syntaxhighlight>
=={{header|Objective-C}}==
Line 938 ⟶ 974:
<span style="color: #0000FF;">?</span><span style="color: #7060A8;">getenv</span><span style="color: #0000FF;">(</span><span style="color: #008000;">"PATH"</span><span style="color: #0000FF;">)</span>
<!--</syntaxhighlight>-->
=={{header|Phixmonti}}==
<syntaxhighlight lang="Phixmonti">/# Rosetta Code problem: http://rosettacode.org/wiki/Environment_variables
by Galileo, 10/2022 #/
def getenv
" > output.txt" chain cmd if "Error!" else "output.txt" "r" fopen dup fgets swap fclose endif
enddef
=={{header|PHP}}==
Line 1,266 ⟶ 1,312:
'X11BROWSER': '/usr/bin/firefox'></pre>
=={{header|V (Vlang)}}==
<syntaxhighlight lang="v (vlang)">// Environment variables in V
// v run environment_variables.v
module main
Line 1,295 ⟶ 1,341:
However, if Wren is embedded in (say) a suitable Go program, then we can ask the latter to obtain it for us.
<syntaxhighlight lang="
class Environ {
foreign static variable(name)
Line 1,304 ⟶ 1,350:
which we embed in the following Go program and run it.
{{libheader|WrenGo}}
<syntaxhighlight lang="go">/*
package main
Line 1,321 ⟶ 1,367:
func main() {
vm := wren.NewVM()
fileName := "
methodMap := wren.MethodMap{"static variable(_)": getEnvironVariable}
classMap := wren.ClassMap{"Environ": wren.NewClass(nil, nil, methodMap)}
|