new example: s:paste word for use w/shared.forth
FossilOrigin-Name: e7e14fd92b12bc05cd11502bb70e1a9c32c376e2cfb2f99e1b64387197fffe6a
This commit is contained in:
parent
4029eb5f12
commit
772e770401
2 changed files with 29 additions and 0 deletions
|
@ -55,6 +55,7 @@
|
||||||
- add net_fetch.forth
|
- add net_fetch.forth
|
||||||
- add Save_and_Restore_Stack.forth
|
- add Save_and_Restore_Stack.forth
|
||||||
- add share.forth and shared.forth
|
- add share.forth and shared.forth
|
||||||
|
- add paste.forth
|
||||||
- switch to dvorak key bindings in Roo.forth
|
- switch to dvorak key bindings in Roo.forth
|
||||||
- remove Hooks.forth (now in core language)
|
- remove Hooks.forth (now in core language)
|
||||||
|
|
||||||
|
|
28
example/paste.forth
Executable file
28
example/paste.forth
Executable file
|
@ -0,0 +1,28 @@
|
||||||
|
#!/usr/bin/env retro
|
||||||
|
|
||||||
|
This implements `s:paste`, a string to private pastebin in
|
||||||
|
RETRO. It uses a Unix pipe to `md5` to create the paste name,
|
||||||
|
keeping in line with the `share.forth` example code.
|
||||||
|
|
||||||
|
It takes a string and returns a pointer to the URL of the
|
||||||
|
paste.
|
||||||
|
|
||||||
|
~~~
|
||||||
|
{{
|
||||||
|
:pipe{ dup 'md5_-s_"%s" s:format file:R unix:popen ;
|
||||||
|
:skip-space dup file:read drop ;
|
||||||
|
:skip-info [ dup file:read $= eq? ] until skip-space ;
|
||||||
|
:get-checksum #127 [ dup file:read , ] here × dip swap ;
|
||||||
|
:} unix:pclose ;
|
||||||
|
:cleanup s:chop s:temp ;
|
||||||
|
:save [ '/home/crc/public/%s s:format file:spew ] sip ;
|
||||||
|
:url 'http://forth.works/%s s:format ;
|
||||||
|
---reveal---
|
||||||
|
:s:paste (s-s)
|
||||||
|
&Heap [ pipe{ skip-info get-checksum } cleanup save url ] v:preserve ;
|
||||||
|
}}
|
||||||
|
~~~
|
||||||
|
|
||||||
|
```
|
||||||
|
'Hello_#forth s:paste s:put nl
|
||||||
|
```
|
Loading…
Reference in a new issue