World: r3wp
[Core] Discuss core issues
older newer | first last |
BrianH 24-Sep-2008 [10978x2] | I haven't written a network protocol in either port model yet (just studied them), so I can't say why you are getting timeouts in this particular case though. |
Later... | |
Robert 4-Oct-2008 [10980] | load/all: Does this skip everything until a REBOL header is found? |
Chris 4-Oct-2008 [10981] | No -- /all assumes all text is data and that the header, if present, is two more values. |
Gregg 4-Oct-2008 [10982] | It can be a bit tricky. LOAD ignores all *lines* before the one where "^/REBOL []" is found. Sunanda is probably the preeminent expoert here, as he dealt with all kinds of loading issues for REBOL.org. |
Chris 4-Oct-2008 [10983] | That's 'load though, not 'load/all |
Sunanda 4-Oct-2008 [10984] | I'm not the expert (thanks all the same, Gregg) but I did start a ML thread in which the real experts looked at key aspects of load and 'load/all for scripts: http://www.rebol.org/ml-display-thread.r?m=rmlTRFQ |
Gregg 4-Oct-2008 [10985] | Correct. |
Terry 4-Oct-2008 [10986] | what's the best way to stich some strings in a block together? ie: "this is a test here" where I parse this, set the first word to 'one, set the second to 'two and everything after that to 'three ? |
Tomc 4-Oct-2008 [10987x3] | one un-tried way |
parse/all str[ (blk: copy []} 2 [copy token to " " (insert tail blk token)] copy token to end (insert tail blk token -- do something with blk ) ] | |
(blk: copy []) | |
Terry 4-Oct-2008 [10990] | Hmm.. my brain is too lazy... I went like this.. ie: "this is a test here" a: parse ie none one: first a two: second a three: reform skip a 2 |
sqlab 5-Oct-2008 [10991] | parse/all ie [copy one to " " skip copy two to " " skip copy three to end] |
Chris 5-Oct-2008 [10992] | ; Terry, with 'take (2.7.6+?) it can be shorter still: three: parse ie none one: take three two: take three three: reform three |
Terry 5-Oct-2008 [10993x2] | cool. |
curious now as to which way is faster? | |
Tomc 5-Oct-2008 [10995] | so the mention of a block in your original question wasn't an actual trequirement |
Terry 6-Oct-2008 [10996] | yeah, I was thinking post parse |
BrianH 6-Oct-2008 [10997x2] | TAKE is slower in R2.7.6+ than R3 because it is a mezzanine (but useful for forward compatibility), and because REMOVE from the beginning of a series is faster in R3. A faster way to do your last example is this: set [one two] three: parse ie none three: reform skip three 2 |
TAKE is one of the most useful new backports from R3 though :) | |
Terry 6-Oct-2008 [10999x2] | Another question. Let's say I have a func .. xyz: func[msg] [print msg] and I have a string "xyz this message" that I convert to a block blk: [xyz "this message" ] How can i set xyz in that block to equal my xyz function.. so that I can DO the block and end up with this message ? |
In other words, execute a string as though it was a function? | |
Sunanda 6-Oct-2008 [11001] | Like this? xyz: func[msg] [print msg] blk: [xyz "this message" ] blk/1: :xyz ;; set the first entry to be the function do blk ;; then do it this message ;; result! |
Terry 6-Oct-2008 [11002x2] | what if you don't know that bkl/1 will be xyz? |
hmm.. this works do load blk | |
Sunanda 6-Oct-2008 [11004] | If you are sure that bl/1 is the word that holds a function: do get to-word blk/1 blk/2 You'll need some error trapping. |
Terry 6-Oct-2008 [11005] | yeah.. and some validation too. |
Sunanda 6-Oct-2008 [11006] | Do load only seems to do what you want: do load ["xxx" "xxx" "xxx" "xxx" "end"] == "end" |
Chris 6-Oct-2008 [11007x2] | ; Also: do load/next "xyz This Message" ; is the same as do [xyz " This Message"] |
func [cmd][ all [ cmd: attempt [load/next cmd] word? cmd/1 value? cmd/1 any-function? get cmd/1 do cmd ] ] | |
Graham 7-Oct-2008 [11009x7] | Never noticed this before |
>> to-file join %test "[0].png" == %test%5B0%5D.png | |
why exactly is this necessary? Is [ and ] special characters in a filing system? | |
Getting really confused now | |
>> f: %test.png == %test.png >> f: %test[0].png ** Script Error: .png has no value ** Near: .png | |
Ok, anyone know how to access a file like this ? test[0].png | |
escaping with ^ doesn't work | |
Steeve 7-Oct-2008 [11016] | file: to-file "test[0].png" seems working on Vista |
Graham 7-Oct-2008 [11017x2] | I'm on vista ... |
>> to-file "test[0].png" == %test%5B0%5D.png | |
Steeve 7-Oct-2008 [11019] | yes but you can read or write with that, it's correctly traduced |
Graham 7-Oct-2008 [11020x3] | I'll try |
Interesting .... | |
works :) | |
Steeve 7-Oct-2008 [11023x2] | ;-) |
i'm wondering what result is produced if the real file name contains various % caracters | |
Graham 7-Oct-2008 [11025] | I don't want to know! |
Steeve 7-Oct-2008 [11026x2] | ha ha |
it's really incredible. >>to-file "test]" == %test%5D >>to-file "test%5D" == %test%5D seems identical, but rebol make the difference. Probably an obscufated stuff in the path. | |
older newer | first last |