AltME groups: search
Help · search scripts · search articles · search mailing listresults summary
world | hits |
r4wp | 5907 |
r3wp | 58701 |
total: | 64608 |
results window for this page: [start: 38901 end: 39000]
world-name: r3wp
Group: Core ... Discuss core issues [web-public] | ||
Graham: 22-Sep-2008 | This is pretty cool .. I just uploaded a 14Mb file using PUT ( though I had to increase the http timeout period ) | |
Louis: 23-Sep-2008 | file: replace/all file {оп} {} Why can't rebol replace that string in the file I'm processing? It will replace it in a string entered at the command console, but not in my file. | |
Henrik: 23-Sep-2008 | it's better to do it on a binary representation of the string, using 'as-binary. the chars you enter in console may not be of the same charset as those you have saved the file in. | |
Louis: 23-Sep-2008 | Henrick, from what you say, I think I see what is happened. I'm copying the string from a utf-8 encoded file to an assci encoded file. The copy converts the string to different characters. But how do I get around this? | |
Henrik: 23-Sep-2008 | you must work solely from the encoding in the file. intermixing input from the console will ruin that. I will post an example in a minute. | |
Henrik: 23-Sep-2008 | what I would do is get the offending chars from your file in a text editor and paste them in a separate file and save it in the same encoding as the original file. then read/binary it with rebol, and you can see the hex values directly. | |
Gabriele: 23-Sep-2008 | Graham, in R3's http you can use any method you want, with any headers you want and any content you want. Was this your question? (I do still need to add transparent cookie support. but that's a few minutes work, so it'll be there for release.) | |
Graham: 24-Sep-2008 | Yes, I saw it .. didn't understand a thing as usual! | |
Graham: 24-Sep-2008 | What I was wondering though was, why should a protocol timeout even though it is still actively communicating ie. sending data to a port? | |
BrianH: 24-Sep-2008 | 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. | |
Robert: 4-Oct-2008 | load/all: Does this skip everything until a REBOL header is found? | |
Gregg: 4-Oct-2008 | 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. | |
Sunanda: 4-Oct-2008 | 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 | |
Terry: 4-Oct-2008 | 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 ? | |
Terry: 4-Oct-2008 | 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 | |
Tomc: 5-Oct-2008 | so the mention of a block in your original question wasn't an actual trequirement | |
BrianH: 6-Oct-2008 | 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 | |
Terry: 6-Oct-2008 | 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 ? | |
Terry: 6-Oct-2008 | In other words, execute a string as though it was a function? | |
Sunanda: 6-Oct-2008 | 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. | |
Graham: 7-Oct-2008 | why exactly is this necessary? Is [ and ] special characters in a filing system? | |
Graham: 7-Oct-2008 | Ok, anyone know how to access a file like this ? test[0].png | |
Anton: 8-Oct-2008 | Yes, that looks like a mold bug. Or it could be a feature ! :) | |
amacleod: 8-Oct-2008 | Any way to find the creation date of a file. I see modified? | |
Gabriele: 8-Oct-2008 | it's not a mold bug, [ is not a valid char in REBOL file! values, it has nothing to do with the OS. | |
Graham: 8-Oct-2008 | I think you can use get-modes on a file to get that data | |
Graham: 8-Oct-2008 | Should that remain that way? [ being a non-valid char in file! type | |
BrianH: 8-Oct-2008 | It's not a restriction, it's REBOL syntax. [ is a delimiter, just like space (which also requires quotes if put in a filename). Parens too. | |
BrianH: 8-Oct-2008 | Because escaping for file! literals is done with %, not ^. The file! type has a different syntax than the string! type. | |
BrianH: 8-Oct-2008 | Anton, Steeve, you have found a bug in file display. The % should definitely be url-encoded. | |
Brock: 9-Oct-2008 | QUESTION: I have a function that takes on parameter. This parameter can be one of many variables. I then want to see what the name of the parameter was that was processed by the function. How do I do this? | |
Brock: 9-Oct-2008 | I'll take a look. Thanks. | |
Brock: 9-Oct-2008 | Hmm, after looking at this, I then have the reverse problem for the remainder of the code, it now doesn't get the value of the parameter that was passed. I'll need to play with this a while longer, but it looks like I'm heading in the right direction. Tx. | |
Terry: 11-Oct-2008 | I knew this at one time, but is there a way to test if a word has been set / exists, that doesn't involve error trapping? >> if error? try [n][print "error"] error | |
Terry: 11-Oct-2008 | Im using it to check a parsed block to see if the value is set.. is there a better way? | |
Claude: 11-Oct-2008 | hi, i would like to know how to open a port with rebol in FTP to connect a ISERIES or IBM I or AS400 and execute commande like this on "quote namemft 1" or "cd /" or "quote syscmd call a PGM" | |
Claude: 11-Oct-2008 | i would like to do it like in dos windows that the FTP command can take a file as input and then execute all commands in that file | |
BrianH: 11-Oct-2008 | If you do to-word "something" in R2 the word returned will be bound to the global context, so it will only have a value if a word of that name in the global context already has a value. It doesn't matter if you do to-word in a function. | |
BrianH: 11-Oct-2008 | Terry, I have found that the best way to check if a value has been set to a word in a parse rule, the best way is to set the word to none before you run the parse rule (or at the beginning of the rule in a paren), then check to see if it is still none afterwards. | |
BrianH: 11-Oct-2008 | You can use NONE? to do that, or the checker for whatever datatype you are looking for if you want a positive result. The IF function also treats NONE as false, so if you are not looking for logic values you can use it directly. Like this: a: none parse [1 2 3] [set a integer!] ; will return false if a [ ; you found it, do something ] If you think the value you are testing might be an active value (like a function), refer to it with a get-word! for safety, like :a. | |
Terry: 11-Oct-2008 | When doing a 'parse block', what's the best way to localize a couple hundred words for post parsing? | |
Chris: 12-Oct-2008 | Could be tidied up a little with an exceptions option... | |
Terry: 12-Oct-2008 | can't seem to get it to fire.. do you have a working example by chance? | |
Chris: 12-Oct-2008 | >> parse "str" localize [a: "str" (probe b: a)] "str" == true >> a ** Script Error: a has no value ** Near: a >> b == "str" | |
Chris: 12-Oct-2008 | localize: func [block /with except /local word words rule][ words: copy [] rule: [set word any-word! (append words word) | into [any rule] | skip] parse block [any rule] forall words [words/1: to-word words/1] words: difference unique union words except except use words compose/only [(block)] ] parse "string" localize/with [a: "str" (probe a) copy b "ing" (probe b)][probe] | |
Gabriele: 13-Oct-2008 | Anton, yes, as Brian says, that looks like a bug. | |
Anton: 13-Oct-2008 | Well, I guess a bug report is due then. Who's responsibility is it ? Graham - I think you :) | |
BrianH: 13-Oct-2008 | Terry, you should consider structuring your parse rules so that you can do more processing of the data you recognize on the fly in parens. When you are using a hundred local words and doing your processing afterwards, you are repeating yourself. | |
Gregg: 13-Oct-2008 | Will, I got away from lit-word! params because they're a pain when you're doing more dynamic things in code. As soon as you want to compute the arg, they get in the way. My classic example is an INCR function. For control funcs, I think they make the calling code read more naturally, and the cases where they cause problems there are much less frequent. | |
Davide: 15-Oct-2008 | hi, I need your help with bind: - I have an object h h: make object! [ q: [] ] append h/q make object! [ f1: func [a][print ["f1" a]] f2: func [b][f1 join "f2 " b] ] if I call f1 and f2 the results are correct: >> h/q/1/f1 "hi" f1 hi >> h/q/1/f2 "hi" f1 f2 hi --------------------- Now, I want to make the code of f2 dynamic, so I add a second param "code" to f2: h/q/1/f2: func [b code][do code] of course this doesn't work, f1 and b aren't bound: >> h/q/1/f2 "hi" [f1 join "f2 " b] ** Script Error: f1 has no value ** Where: f2 ** Near: f1 join "f2 " b I've tried with no luck the followings: h/q/1/f2: func [b code][do bind code 'f2] h/q/1/f2: func [b code][do bind code in h/q/1 'f2] What is the magic word: "do bind code ******* " ? | |
amacleod: 16-Oct-2008 | Is there a simple method or do I need to parse through and append each line while inserting the ^/ | |
Anton: 16-Oct-2008 | Geomol, I was like that too, for quite some time, at the beginning. But... we can teach it to you !! It's really a simple concept. | |
Geomol: 16-Oct-2008 | I know the concept of a context. I actually use the word CONTEXT in most of my scripts. And reading the BIND help (with ? bind), I see, it binds words to a known word. So I guess, the known word is defining the context, the new words (1. argument of BIND) should bind to. But why, Anton, do you use two binds in your example? I would guess, something like: do bind [code b] h/q/1 should work? | |
Geomol: 16-Oct-2008 | amacleod, you might get confused by some small inconsistent in REBOL? >> {a { ^-b} == "a^/^-b" >> {a { ^-b { ^-c} == {a ^-b ^-c} | |
Anton: 16-Oct-2008 | Geomol, yes the known word just defines the context. I use two binds because there are two contexts involved - the h/q/1 context, and the function's context. (Each time you create a function, a context is created for its locals.) | |
Anton: 16-Oct-2008 | What we want is to bind the words *inside* the block that 'code refers to. Bind considers each word inside the block, checking to see if they are in the target context. If so, they are rebound to the target context. This step essentially gives the words a useful meaning, the meaning that's intended, and the meaning that's defined in the target context, not in some other context like the global context. | |
Anton: 16-Oct-2008 | So BIND selectively "paints" a context over words in a block. BIND recurses into sub-blocks to do this, but does not get the value of words and recurse into them too, if they are blocks. This is why bind [code] ctx does not affect the CODE block; it only affects the 'code word (and only that instance of the 'code word, not any other instances floating around elsewhere in the system, in their own blocks.) | |
Anton: 16-Oct-2008 | Davide, that is not possible in rebol, because there is no concept of "here". That is, there is no "current" context. That's just an illusion created by groups of words travelling together in blocks. Every word has its own binding. Just because several words in a block often have the same binding does not mean that the block knows anything of the context. This word-binding is a unique feature of rebol, and people used to other languages confuse it for scope, which is less flexible. | |
Geomol: 16-Oct-2008 | Why is it, that b is not auto-bound to the function in this example? >> f: func [b code] [do code] >> f "hi" [print b] ** Script Error: b has no value I mean, passing [print b] as an argument to the function, it's just a block of words without meaning initially. When handed to f, f takes over and will now do it. So f has to find out, what's the meaning of the inside of the block. First it finds the word "print", which makes sense. Then it find the word "b", and this doesn't makes sense to f. Why not? | |
amacleod: 16-Oct-2008 | Why: >> {a { b { c} == "a^/b^/c" but: {a { ^-b { ^-^-c} == {a ^-b ^-^-c} | |
amacleod: 16-Oct-2008 | {a^/^-b^/^-^-c} | |
Anton: 16-Oct-2008 | Geomol, when FUNC is evaluated, a new function is created, along with a new "function context", as we say. The words in the function body block are then bound to the new function context. There are only two words in the block, 'do and 'code. So those are the only words affected. This binding only happens *once*, at function creation time. It does not happen again automatically when the function is evaluated for the first time, or any time afterwards. Even if it did, it would not affect the block of words referred to by 'code, because, as I've said above, BIND does not evaluate words to check if they are a block so it can recurse into them. (If it did, that would have far reaching consequences.) Not having to rebind words each time the function is evaluated keeps it efficient. If we want 'foreign' code to be bound to a function's context so it can interact with the function's locals, then we have to do it ourselves; functions created by FUNC won't do it for us. | |
Geomol: 16-Oct-2008 | I see. If it's more efficient (faster) this way, then it's a good thing! :-) I (and others) just have to remember it and act accordingly. | |
Anton: 16-Oct-2008 | Actually, it would be quite annoying for functions to automatically bind code like that. Suppose we had a code block and we wanted to send it somewhere, and to get there it must pass through a few functions not authored by us. Will the code make it, retaining its meaning ? That depends on whether we accidentally used any words that happen to be the same name as locals of the functions involved. If we did use such a word, then it would be rebound to a function's context and change its meaning. That's not typically how functions are supposed to be used. Functions are supposed to hide their implementation details from the outside world, and have no side-effects. | |
Geomol: 16-Oct-2008 | I used to think, blocks of words didn't have any meaning, until they were e.g. evaluated. In one context, the words mean one thing, in another something else. When I program, I don't think alot about this, I just work with REBOL. Now I some cases, where I might not expect the output, I'm getting. Example: >> a: 1 == 1 >> f: func [a code] [do code] >> f 2 [print a] 1 Before doing this, I would have guessed, 2 was printed. Funny I haven't had such a problem, that I can remember. | |
Geomol: 16-Oct-2008 | Remembering some discussion about block pre-evaluation or something. So the interior of blocks are being giving meaning, when they are born. And you can't put anything in a block: >> blk: [a 7-] ** Syntax Error: Invalid date -- 7- | |
Anton: 16-Oct-2008 | Geomol, you're right, actually, the real meaning of a word is only ever actualised when it is evaluated. But you can think of a word's binding as its potential meaning. (Above, I wrote as if binding and meaning are the same, whereas they are not quite; they are close, but binding is one step back from meaning.) | |
amacleod: 16-Oct-2008 | s: {a { ^-b { ^-^-c} == {a ^-b ^-^-c} replace/all s "^/" "^^/" == {a^^/^-b^^/^-^-c} >> print s a^/ b^/ c Not what I want. | |
amacleod: 16-Oct-2008 | s2: copy a parse/all s2 [some [p: "^/" (change/part p "^^/" 1) skip | "^-" (chang e/part p "^^-" 1) skip | skip]] == true >> s2 == {a^^/^^-b^^/^^-c} >> print s2 a^/^-b^/^-c Anton, It looks like what I want but if aI print it the newlines are not reconized??? | |
amacleod: 16-Oct-2008 | But if I do it manually: >> z: {a^/^-b^/^-^-c} == {a ^-b ^-^-c} >> probe z {a ^-b ^-^-c} == {a ^-b ^-^-c} I do not get it. Are there hidden characters? | |
Gregg: 16-Oct-2008 | By adding the secon ^, it escapes the ^ that marks the newline, so it is no longer a newline. When you write the string out, then it will write out as "a^/^-b^/^-c" which will convert to newlines again when loaded. If you're writing out and loading strings, you may have to convert the data back yourself when you load it, because REBOL won't parse into it to do so. e.g., if you mold an object spec to be on a single line like that, REBOL will convert them on load, but if you just read a file as a string, it won't. | |
Anton: 16-Oct-2008 | Check it out: >> "a^/b" == "a^/b" >> "a^/^-b" == "a^/^-b" >> "a^/^-b^/" == "a^/^-b^/" >> "a^/^-b^/^-^-c" == {a ^-b ^-^-c} | |
amacleod: 16-Oct-2008 | Greg, I tried wrote it out ot a file and loaded it but it still does not print properly Is there a work around? | |
Anton: 16-Oct-2008 | amacleod, I think Greg and mine solution both work. They produce a string molded so that the two control characters (newline and tab) are escaped. You just need to ... ahh... here's where I was going to say "just LOAD it." but I get an error message. >> load "^^/" ** Syntax Error: Invalid path -- ^/ ** Near: (line 1) ^/ So maybe do this instead: s: "^/" ; <-- input string s: "^^/" ; <--- specially "molded" string as produced by PARSE or REPLACE above. load rejoin ["{" s "}"] ; <-- specially "loaded" string the result of which should be the same as the input. | |
Anton: 16-Oct-2008 | >> s: "a^/^-b^/^-^-c" == {a ^-b ^-^-c} >> s2: copy s parse/all s2 [some [p: "^/" (change/part p "^^/" 1) skip | "^-" (change/part p "^^-" 1) skip | skip]] == true >> s3: load rejoin ["{" s "}"] == {a ^-b ^-^-c} >> s = s3 == true | |
amacleod: 16-Oct-2008 | Did you mean: s3: load rejoin ["{" s2"}"] ? with s2 in the rejoin and not s ? That seems to work and produce what I'm tring to get... A little awkward but only two lines for what I want... Thanks again, Anton. I can use this in the short time but I may need to just use SQLite or my own solution for storage as Paul is no longer developing Tretbase... | |
Geomol: 16-Oct-2008 | amacleod, can you use NicomDB? http://www.fys.ku.dk/~niclasen/nicomdb/index.html NicomDB is the result of an education, I took some years ago. More info: http://www.fys.ku.dk/~niclasen/nicomdb/thesis.pdf There's also a group about it here in the REBOL3 world. See group !NicomDB | |
amacleod: 17-Oct-2008 | Idid a quick glance through your paper and it had a lot of good iseas that might fit my needs. I'm going to play around with it. Are you still developing it? | |
Gregg: 18-Oct-2008 | From !REBOL3 group, following MattAnton's fbionacci func. Matt, it's a good func, but there are some things to watch out for in REBOL, which are different from many other languages. 1) Undeclared vars in func become global. Use the /local refinement to declare them. 2) Series values in funcs (e.g. your starting block of [0.0 1.0] maintain their value between calls if you don't use COPY. Run your function multiple times to see what happens. It may be that you wanted this to be a memoizing function, but then why UNSET 'fibonacci-block?. I think you also mentioned that the challenge was to do it recursively, which this isn't. That's a case where you would definitely want to memoize. :-) In any case, this is always fun stuff to think about. Here's a modified version for you to play with. Look at some of the other REBOL funcs used, see if you find any bugs, or maybe it will give you ideas for other ways to solve the problem. fibonacci: func [ "Returns a list of fibonacci numbers, up to the specified count." count [integer!] "Number of iterations to run" /trace /local res n-1 n-2 incr step ] [ incr: func [word] [set word 1 + get word] step: does [incr 'n-1 incr 'n-2] res: copy [0.0 1.0] set [n-1 n-2] [1 2] repeat i count [ append res add pick res n-1 pick res n-2 step if trace [print [i last res]] ] res ] print mold fibonacci 3 print mold fibonacci 46 | |
Dockimbel: 18-Oct-2008 | Here's my attempt with a caching and fully recursive version : fibonacci: func [n /local f][ f: [0.0 1.0] either f/(n + 1) [copy/part f n + 1][ fibonacci n - 1 append f f/:n + f/(n - 1) ] ] probe fibonacci 3 probe fibonacci 46 probe fibonacci 8 Note that : 1) The last call with 8 value is just an extraction of the pre-computed cached sequence (cached values up to 46th by the previous call), so it executes in 0(1). 2) References to 'n (except fibonacci n - 1) are incremented by 1 to account for REBOL series 1-based indexes. If we could switch to 0-based indexes, the function source would be more readable (closer to the pure algorithm). | |
Robert: 19-Oct-2008 | Can someone help me with this? >> open tcp://:12345 >> open tcp://:12345 ** Access Error: Error opening socket listen port ** Near: open tcp://:12345 >> a: 12345 == 12345 >> open tcp://:a >> open tcp://:a >> | |
Robert: 19-Oct-2008 | How can I use 'a as a reference to port 12345 as well? | |
Graham: 19-Oct-2008 | >> a: 1234 == 1234 >> p: open join tcp://: a >> close p >> p: open join tcp://: a >> p: open join tcp://: a ** Access Error: Error opening socket listen port ** Near: p: open join tcp://: a >> close p | |
Graham: 19-Oct-2008 | p: open tcp://::a | |
Graham: 25-Oct-2008 | perhaps we can get a /utc option for date types?? | |
Gregg: 25-Oct-2008 | REBOL.org has a couple ISO date formatting funcs, though I think a lot of us roll our own, sometimes ad hoc. It depends, too, on how flexible--or accepting of various inputs--you want it to be. | |
Gregg: 25-Oct-2008 | as-utc: func [date] [ if all [date/zone 0:00 <> date/zone] [ date: add date negate date/zone ] date/zone: none if none? date/time [date/time: 0:0:0] date ] to-ISO8601-date: func [ "Converts a date! value to an ISO 8601 format string." date [date!] "The date to format" /T {Use T to delimit time value, rather than a space} /no-zone "Don't include the timezone" /local pad z ][ pad: func [val /to len] [ val: form val head insert/dup val #"0" ((any [len 2]) - length? val) ] rejoin [ pad/to date/year 4 "-" pad date/month "-" pad date/day either T ["T"] [" "] either none? t: date/time ["00:00:00Z"] [ ;<< reusing 'T here! rejoin [ pad t/hour ":" pad t/minute ":" pad round t/second either no-zone [""] [ either 0:00 = z: date/zone ["Z"] [ ;<< setting 'z here! rejoin [ pick ["+" "-"] z/hour > 0 pad abs z/hour pad abs z/minute ] ] ] ] ] ] ] | |
Gregg: 25-Oct-2008 | I looked at some of my stuff but, for some reason, I don't seem to have one that does the 0.0 format for seconds. Even my FORMAT func doesn't work for that, though it would shorten the rejoins a bit. e.g. form-as-utc: func [date] [ format as-utc date "yyyy-mm-dd\Thhh:mm:ss\Z" ] Just have to change that last part for the seconds. But I can't remember if I've published FORMAT. | |
Gregg: 25-Oct-2008 | Yeah, I've seen that format as a standard, which is why I don't know why I don't have that. Must not have needed it. :-\ | |
Chris: 25-Oct-2008 | do http://www.rebol.org/download-a-script.r?script-name=form-date.r form-date now "%Y-%m-%dT%H:%M:%SZ%Z" form-date/gmt now "%Y-%m-%dT%H:%M:%s" | |
Chris: 25-Oct-2008 | do http://www.rebol.org/download-a-script.r?script-name=form-date.r pad-precise: func [s [number!]][ skip tail rejoin ["0" round/to s 0.1] -4] form-date now "%Y-%m-%dT%H:%M:%SZ%Z" form-date/gmt now "%Y-%m-%dT%H:%M:%s" | |
Chris: 25-Oct-2008 | (a hack -- 'pad-precise shouldn't be global) | |
Graham: 25-Oct-2008 | anyone have a nice word that does this | |
Graham: 25-Oct-2008 | I do this a lot to make sure there is no text overflow in database fields | |
Anton: 27-Oct-2008 | Can't you just use a word ? | |
BrianH: 27-Oct-2008 | Anton, the R3 clean-path is a mezzanine which only applies REBOL expansion rules, not OS-specific ones. | |
Anton: 27-Oct-2008 | Aha, I see, clean-path is a much longer function, now that it's not using get-modes. | |
BrianH: 27-Oct-2008 | ~ is a valid character for filenames on some platforms though. | |
Gregg: 27-Oct-2008 | 'Cut doesn't seem like a good name for this. 'Cut is a *nix command that lets you "cut out" the columns you want from data. And if you say "cut ["Gregg Irwin" 5], does that mean to cut five chars or keep them, and from which end? I think 'keep is a better word for this, or maybe 'cut-to. BTW, I have the same naming issue with my PAD func. i.e. does pad/right mean pad *to* the right, or *on* the right. Sometimes you just have to live with a bit of ambiguity. | |
BrianH: 27-Oct-2008 | KEEP is used elsewhere. This is more of a constraint. Perhaps cut-length or something like that. |
38901 / 64608 | 1 | 2 | 3 | 4 | 5 | ... | 388 | 389 | [390] | 391 | 392 | ... | 643 | 644 | 645 | 646 | 647 |