Execute a system command: Difference between revisions

m
(Added unix function/statement in F 7.0.23)
m (→‎{{header|Wren}}: Minor tidy)
(One intermediate revision by one other user not shown)
Line 692:
FB 7.0.23+
<syntaxhighlight lang="futurebasic">
unixprint unix(@"ls -A")
</syntaxhighlight>
Classic FB using Pascal strings
<syntaxhighlight>
local fn DoUnixCommand( cmd as str255 )
dim as str255 s
 
open "Unix", 2, cmd
Line 2,238:
However, if Wren is embedded in (say) a suitable Go program, then we can ask the latter to do it for us.
 
<syntaxhighlight lang="ecmascriptwren">/* run_system_commandExecute_a_system_command.wren */
class Command {
foreign static exec(name, param) // the code for this is provided by Go
Line 2,249:
which we embed in the following Go program and run it.
{{libheader|WrenGo}}
<syntaxhighlight lang="go">/* run_system_commandExecute_a_system_command.go*/
package main
 
Line 2,280:
func main() {
vm := wren.NewVM()
fileName := "run_system_commandExecute_a_system_command.wren"
methodMap := wren.MethodMap{"static exec(_,_)": execCommand}
classMap := wren.ClassMap{"Command": wren.NewClass(nil, nil, methodMap)}
9,482

edits