From 772e770401b71957acaa16c5314928a3cadc68de Mon Sep 17 00:00:00 2001 From: crc Date: Sat, 19 Jan 2019 05:29:15 +0000 Subject: [PATCH] new example: s:paste word for use w/shared.forth FossilOrigin-Name: e7e14fd92b12bc05cd11502bb70e1a9c32c376e2cfb2f99e1b64387197fffe6a --- RELEASE_NOTES.md | 1 + example/paste.forth | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100755 example/paste.forth diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index fe4b3e4..9617a16 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -55,6 +55,7 @@ - add net_fetch.forth - add Save_and_Restore_Stack.forth - add share.forth and shared.forth +- add paste.forth - switch to dvorak key bindings in Roo.forth - remove Hooks.forth (now in core language) diff --git a/example/paste.forth b/example/paste.forth new file mode 100755 index 0000000..d98fac9 --- /dev/null +++ b/example/paste.forth @@ -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 +```