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 +```