Skip to content

Instantly share code, notes, and snippets.

@greggirwin
Forked from dockimbel/load-any.red
Created March 23, 2017 17:53
Show Gist options
  • Save greggirwin/d1492b2dd57b94465f8f98a2001b7872 to your computer and use it in GitHub Desktop.
Save greggirwin/d1492b2dd57b94465f8f98a2001b7872 to your computer and use it in GitHub Desktop.
Experimental generic loader for non-Red input text.
Red []
load-any: function [input [string!]][
out: make block! 100
junk: none
until [
result: load/trap/next input 'pos
either error? result/3 [
append any [junk junk: make string! 20] result/2/1
input: next result/2
][
if junk [
append out #junk
append out junk
junk: none
]
input: result/2
]
append out result/1
empty? result/2
]
out
]
;; load-any "aaa 456z 3 abc"
;; == [aaa #junk "456" z 3 abc]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment