AltME: Rebol School

Messages

Endo
@sqlab: I meant uploading a file via already open port!
ftp-port: open ftp://localhost/
; do something ...
; upload using ftp-port, how?
insert, poke, append etc. don't work..
@sqlab: I meant uploading a file via already open port!
ftp-port: open ftp://localhost/
; do something ...
; upload using ftp-port, how?
insert, poke, append etc. don't work..
oh my internet connection problem leads to multiple send, sorry about that.

sqlab
If I remember right, Rebol2 should cache an already opened port to the same destination an reuse it for follwing actions.

Endo
Hi Ashley, I started using Munge in a project, it is great, thank you for all your effort.
First of all, I couldn't find a group for munge, it would be better to have !munge or #munge group in Altme. So I'm writing here.
I would like to ask my questions & share my experiences here.
First one is a possible bug report:
worksheet/save ["Name" "Age" "Bob" 33 "Joe" 44] 2 %t.xlsx  ;this one works as expected
worksheet/save ["Name" "Age" "Bob" 33 "Joe" 44] 2 %t.xml  ;this one creates a .xml file which has 3 sheet with same data.
Gregg
Semseddin/Endo, if you can't find a group, create one. You should have rights to do so.

Endo
Anyone already wrote a function something like REPLACE-DEEP (similar to COMPOSE/DEEP) which deeply replace any match in a given block:
>> REPLACE-DEEP [ 1 [  2 "one" [ 3 "one" <something-else> ] ] ] "one" "two"
== [ 1 [  2 "two" [ 3 "two" <something-else> ] ] ]
I know it's not difficult using PARSE, but if anyone has already wrote, I don't waste my time. Thanks in advance.
Rebolek
Endo
Ah thanks! I wrote mine, I'll compare them.
replace-deep: func [ series [series!] value1 value2 /local rule m] [
    rule: [
        some [
            into rule
            |
            m: any-type! (if :value1 = first m [probe m: insert remove m :value2] :m)
            |
            skip
        ]
    ]
    parse series rule
]

DocKimbel
replace-deep: func [s [any-block!] value new /local rule pos][
    parse s rule: [any [pos: value (pos/1: new) | into rule | skip]]
    s
]
Gregg
Niiiiice. :-)
All of them, that is.
Endo
I think all of them have some problems including mine.
Doc: Your version stuck if no match:
>> replace-deep x: [a] 1 2   ;waits for ever
My version stucks if new value is a block that includes the search value:
>> replace-deep x: [a b [b] b] 'a [a b a]  ;infinite loop
Rebolek: Your version doesn't work for some values
>> replace-deep3 x: [1 2] 2 3  ; x stays unchanged
Rebolek
Oh, integers...
DocKimbel
It might be very complicated to achieve it using PARSE in Rebol2 due to the lack of escaping mechanism for words and integers like QUOTE in Red and Rebol3.
In Red, this version passes all the tests:
replace-deep: func [s [any-block!] value new /local rule pos][
    rule: [any [pos: quote _ (pos/1: new) | into rule | skip]]
    rule/2/3: value
    parse s rule
    s
]
probe replace-deep x: [a] 1 2
probe replace-deep x: [a b [b] b] 'a [a b a]
probe replace-deep x: [1 2] 2 3
[a]
[[a b a] b [b] b]
[1 3]
Rebolek
Endo's replace function (m: any-type! and then check for values in paren!) can do it
Nenad, your version is missing  ANY-STRING! rule before INTO RULE rule to ignore string!s, otherwise INTO will try to parse inside them.
DocKimbel
Indeed, with an INSERT/ONLY instead of INSERT, it would pass the second test.
Any-string!: good point.
Endo: the [ | skip ] part of your rule looks superfluous.

Last message posted 184 weeks ago.