Environment variables: Difference between revisions
→{{header|langur}}
No edit summary |
Langurmonkey (talk | contribs) |
||
(One intermediate revision by one other user not shown) | |||
Line 582:
writeln "USER: ", _env["USER"]</syntaxhighlight>
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
Line 1,338 ⟶ 1,337:
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,347 ⟶ 1,346:
which we embed in the following Go program and run it.
{{libheader|WrenGo}}
<syntaxhighlight lang="go">/*
package main
Line 1,364 ⟶ 1,363:
func main() {
vm := wren.NewVM()
fileName := "
methodMap := wren.MethodMap{"static variable(_)": getEnvironVariable}
classMap := wren.ClassMap{"Environ": wren.NewClass(nil, nil, methodMap)}
|