Issues with file:read hmmm
This commit is contained in:
parent
d1b94eeb29
commit
2454f1e83f
|
@ -4,7 +4,7 @@ Let's try and see if we can use bi-directional pipes in [Retro Forth](http://for
|
|||
|
||||
## Run Application
|
||||
|
||||
```
|
||||
```bash
|
||||
./pipes.retro
|
||||
```
|
||||
|
||||
|
|
48
pipes.html
48
pipes.html
|
@ -55,10 +55,56 @@
|
|||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<span class='text'>#!/usr/bin/env retro</span><br>
|
||||
<span class='text'></span><br>
|
||||
<span class='text'># Bi-Directional Pipes in Retro</span><br>
|
||||
<span class='text'></span><br>
|
||||
<span class='text'></span><br>
|
||||
<span class='text'>## Configuration</span><br>
|
||||
<span class='text'></span><br>
|
||||
<span class='text'>Let's set some constants and a string template</span><br>
|
||||
<span class='text'></span><br>
|
||||
~~~<br>
|
||||
<span class='string'>'Hello,_world!</span> s:puts <br>
|
||||
<span class='string'>'23</span> <span class='string'>'PORT</span> const <br>
|
||||
<span class='string'>'localhost</span> <span class='string'>'HOST</span> const <br>
|
||||
<span class='string'>'telnet_%s:%s</span> <span class='string'>'TEMPLATE</span> const <br>
|
||||
~~~<br>
|
||||
<span class='text'></span><br>
|
||||
<span class='text'>And now that we have configurable variables, let's make a template of the shell command we need for `unix:popen`</span><br>
|
||||
<span class='text'></span><br>
|
||||
~~~<br>
|
||||
PORT HOST TEMPLATE s:format <br>
|
||||
~~~<br>
|
||||
<span class='text'></span><br>
|
||||
<span class='text'>We've now got a formatted string on the stack. Probably looks like `telnet materiamagica.com:4000`. Isn't RPN funny?</span><br>
|
||||
<span class='text'></span><br>
|
||||
<span class='text'>Let's save that for later:</span><br>
|
||||
<span class='text'></span><br>
|
||||
~~~<br>
|
||||
<span class='string'>'SHELL_CMD</span> const <br>
|
||||
~~~<br>
|
||||
<span class='text'></span><br>
|
||||
<span class='text'>## Prepare the Shell Command</span><br>
|
||||
<span class='text'></span><br>
|
||||
<span class='text'>Let's get a file handle:</span><br>
|
||||
<span class='text'></span><br>
|
||||
~~~<br>
|
||||
SHELL_CMD file:R+ unix:popen <br>
|
||||
~~~<br>
|
||||
<span class='text'></span><br>
|
||||
<span class='text'>...and save it as `TELNET_FD`:</span><br>
|
||||
<span class='text'></span><br>
|
||||
~~~<br>
|
||||
<span class='string'>'TELNET_FD</span> const <br>
|
||||
~~~<br>
|
||||
<span class='text'></span><br>
|
||||
<span class='text'>## Is This Thing On?</span><br>
|
||||
<span class='text'></span><br>
|
||||
~~~<br>
|
||||
TELNET_FD file:read s:put <br>
|
||||
~~~<br>
|
||||
<span class='text'></span><br>
|
||||
<span class='text'></span><br>
|
||||
<span class='text'>I don't have any more time for tonight to keep coding sorry.</span><br>
|
||||
</body>
|
||||
</html>
|
||||
|
|
46
pipes.retro
46
pipes.retro
|
@ -2,6 +2,50 @@
|
|||
|
||||
# Bi-Directional Pipes in Retro
|
||||
|
||||
|
||||
## Configuration
|
||||
|
||||
Let's set some constants and a string template
|
||||
|
||||
~~~
|
||||
'Hello,_world! s:put
|
||||
'23 'PORT const
|
||||
'localhost 'HOST const
|
||||
'telnet_%s:%s 'TEMPLATE const
|
||||
~~~
|
||||
|
||||
And now that we have configurable variables, let's make a template of the shell command we need for `unix:popen`
|
||||
|
||||
~~~
|
||||
PORT HOST TEMPLATE s:format
|
||||
~~~
|
||||
|
||||
We've now got a formatted string on the stack. Probably looks like `telnet materiamagica.com:4000`. Isn't RPN funny?
|
||||
|
||||
Let's save that for later:
|
||||
|
||||
~~~
|
||||
'SHELL_CMD const
|
||||
~~~
|
||||
|
||||
## Prepare the Shell Command
|
||||
|
||||
Let's get a file handle:
|
||||
|
||||
~~~
|
||||
SHELL_CMD file:R+ unix:popen
|
||||
~~~
|
||||
|
||||
...and save it as `TELNET_FD`:
|
||||
|
||||
~~~
|
||||
'TELNET_FD const
|
||||
~~~
|
||||
|
||||
## Is This Thing On?
|
||||
|
||||
~~~
|
||||
TELNET_FD file:read s:put
|
||||
~~~
|
||||
|
||||
|
||||
I don't have any more time for tonight to keep coding sorry.
|
||||
|
|
Loading…
Reference in New Issue