Hostname: Difference between revisions

m
m (syntax highlighting fixup automation)
m (→‎{{header|Wren}}: Minor tidy)
 
(5 intermediate revisions by 5 users not shown)
Line 38:
=={{header|Arc}}==
<syntaxhighlight lang="arc">(system "hostname -f")</syntaxhighlight>
 
=={{header|Arturo}}==
 
<syntaxhighlight lang="arturo">print sys\hostname</syntaxhighlight>
 
{{out}}
 
<pre>drkameleons-Mac.home</pre>
 
=={{header|AutoHotkey}}==
Line 274 ⟶ 282:
=={{header|Frink}}==
<syntaxhighlight lang="frink">callJava["java.net.InetAddress", "getLocalHost"].getHostName[]</syntaxhighlight>
 
 
=={{header|FutureBasic}}==
}</syntaxhighlight lang="futurebasic">
include "NSLog.incl"
NSLog( @"%@", fn ProcessInfoHostName )
HandleEvents
</syntaxhighlight>
 
 
=={{header|Gambas}}==
Line 360 ⟶ 377:
 
=={{header|Java}}==
<syntaxhighlight lang="java">import java.net.*;
import java.net.InetAddress;
class DiscoverHostName {
import java.net.UnknownHostException;
public static void main(final String[] args) {
</syntaxhighlight>
try {
<syntaxhighlight lang="java">
System.out.println(InetAddress.getLocalHost().getHostName());
void printHostname() }throws catch (UnknownHostException e) { // Doesn't actually happen, but Java requires it be handled.
InetAddress localhost = InetAddress.getLocalHost();
}
System.out.println(InetAddress.getLocalHost()localhost.getHostName());
}
}</syntaxhighlight>
</syntaxhighlight>
<pre>
penguin
</pre>
 
=={{header|JavaScript}}==
Line 904 ⟶ 925:
=={{header|Slate}}==
<syntaxhighlight lang="slate">Platform current nodeName</syntaxhighlight>
 
=={{header|Slope}}==
<syntaxhighlight lang="slope">(hostname)</syntaxhighlight>
 
=={{header|Smalltalk}}==
Line 1,015 ⟶ 1,039:
End Sub</syntaxhighlight>
 
=={{header|V (Vlang)}}==
In Vlang, the "main()" entry point and declaration can be skipped in one file programs and when used like a script.
<syntaxhighlight lang="v (vlang)">import os
 
println(os.hostname())</syntaxhighlight>
Line 1,026 ⟶ 1,050:
However, if Wren is embedded in (say) a suitable Go program, then we can ask the latter to get it for us.
 
<syntaxhighlight lang="ecmascriptwren">/* hostnameHostname.wren */
class Host {
foreign static name() // the code for this is provided by Go
Line 1,035 ⟶ 1,059:
which we embed in the following Go program and run it.
{{libheader|WrenGo}}
<syntaxhighlight lang="go">/* hostnameHostname.go */
package main
 
Line 1,052 ⟶ 1,076:
func main() {
vm := wren.NewVM()
fileName := "hostnameHostname.wren"
methodMap := wren.MethodMap{"static name()": hostname}
classMap := wren.ClassMap{"Host": wren.NewClass(nil, nil, methodMap)}
9,476

edits