Get system command output: Difference between revisions

Added XPL0 example.
m (BaCon moved to the BASIC section.)
(Added XPL0 example.)
 
(3 intermediate revisions by 2 users not shown)
Line 117:
#include <jambo.h>
Main
sys = `cat jm/sus1sys1.jambo`
Set( sys ) Prnl
End
Line 1,408:
We use <code>#lang racket/base</code> to show which module system is in. It would be imported anyway if we use the larger <code>#lang racket</code>.
 
This demonstrates one function: <code>system</system></code>. It is the simplest of a family of commands in the <code>racket/system</code> collection.
 
See [http://docs.racket-lang.org/reference/subprocess.html?q=system#%28def._%28%28lib._racket%2Fsystem..rkt%29._system%29%29 documentation for <code>system</code> and friends].
Line 1,760:
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">/* get_system_command_outputGet_system_command_output.wren */
class Command {
foreign static output(name, param) // the code for this is provided by Go
Line 1,769:
which we embed in the following Go program and run it.
{{libheader|WrenGo}}
<syntaxhighlight lang="go">/* get_system_command_outputGet_system_command_output.go */
package main
 
Line 1,800:
func main() {
vm := wren.NewVM()
fileName := "get_system_command_outputGet_system_command_output.wren"
methodMap := wren.MethodMap{"static output(_,_)": getCommandOutput}
classMap := wren.ClassMap{"Command": wren.NewClass(nil, nil, methodMap)}
Line 1,808:
vm.Free()
}</syntaxhighlight>
 
=={{header|XPL0}}==
Use a pipe on the command line to run this. For example: dir | syscmd
<syntaxhighlight lang "XPL0">int C;
repeat C:= ChIn(1);
if C>=^a & C<=^z then \lowercase letters to uppercase
C:= C & ~$20;
ChOut(0, C);
until C = $1A</syntaxhighlight>
 
=={{header|Yabasic}}==
295

edits