Environment variables: Difference between revisions

Add SmallBASIC
m (syntax highlighting fixup automation)
(Add SmallBASIC)
 
(9 intermediate revisions by 8 users not shown)
Line 191:
 
<syntaxhighlight lang="is-basic">ASK machine-option-code var</syntaxhighlight>
 
==={{header|SmallBASIC}}===
<syntaxhighlight lang="langurqbasic">writeln "HOME: ", _env'HOME
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 "HOME: ", _env["HOME"]
writeln "PATHHOME: ", _env["PATH"]'HOME
writeln "USER: ", _env["USER"]</syntaxhighlight>
 
{{works with|langur|0.9}}
We could also the short-hand form of indexing by string. This is limited to code points used for tokens and does not allow for spaces, nor an index alternate.
<syntaxhighlight lang="langur">writeln "HOME: ", _env'HOME
writeln "PATH: ", _env'PATH
writeln "USER: ", _env'USER</syntaxhighlight>
</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
 
writeln "USER: path", _env["USER"]getenv print</syntaxhighlight>
 
=={{header|PHP}}==
Line 1,134 ⟶ 1,180:
<syntaxhighlight lang="slate">Environment variables at: 'PATH'.
"==> '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games'"</syntaxhighlight>
 
=={{header|Slope}}==
<syntaxhighlight lang="slope">(env "HOME")</syntaxhighlight>
 
=={{header|Smalltalk}}==
Line 1,263 ⟶ 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,292 ⟶ 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="ecmascriptwren">/* environment_variablesEnvironment_variables.wren */
class Environ {
foreign static variable(name)
Line 1,301 ⟶ 1,350:
which we embed in the following Go program and run it.
{{libheader|WrenGo}}
<syntaxhighlight lang="go">/* environment_variablesEnvironment_variables.go */
package main
 
Line 1,318 ⟶ 1,367:
func main() {
vm := wren.NewVM()
fileName := "environment_variablesEnvironment_variables.wren"
methodMap := wren.MethodMap{"static variable(_)": getEnvironVariable}
classMap := wren.ClassMap{"Environ": wren.NewClass(nil, nil, methodMap)}
26

edits