r3wp [groups: 83 posts: 189283]
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

World: r3wp

[Core] Discuss core issues

BrianH
24-May-2006
[4719]
I was a little surprised that the lit-word didn't turn into a word. 
That could be useful. I'm going to do some experiments to see what 
else reduce/only doesn't do. Should be fun.
Rebolek
24-May-2006
[4720]
Why I am not able to OPEN file which I can READ ?
Graham
24-May-2006
[4721x2]
Example?
'read must 'open a file
Ladislav
24-May-2006
[4723]
Open/read may be the difference
Rebolek
24-May-2006
[4724]
Ladislav yes, that was the problem, thanks
JaimeVargas
24-May-2006
[4725]
Ashley, but reduce/only doesn't perform according to your  initial 
spec "Evaluates a block of expressions, skipping words without a 
value, and returns a block."
>> reduce/only [now then]
** Script Error: then has no value
Anton
24-May-2006
[4726x2]
Huh? that's not the error I get:
>> reduce/only [now then]

** Script Error: reduce expected words argument of type: block none
** Near: reduce/only [now then]
Ah but maybe that's still your point - not what Ashley asked for.
Volker
24-May-2006
[4728]
Docu is wrong. it does not reduce words in the /only block. But it 
also rejects functions. so
>> reduce/only[then][then]
== [then]
but it also rejects functions, here unfortunally:
>> reduce/only[now][]
** Script Error: Invalid argument: now
because of security-reasons (draw-blocks from untrusted code).
Ashley
24-May-2006
[4729]
but reduce/only doesn't perform according to your  initial spec
 True, on two counts:

1) It doesn't evaluate expressions (even if parenthesized)

2) You have to predetermine what words to ignore (less of an issue 
for dialects)

I still can't see a simple way of doing the following:

>> reduce [b: button red form now/date]
** Script Error: button has no value
** Near: b: button red form now/date
>> reduce/only [b: button red form now/date] [button]
** Script Error: Invalid argument: form
** Near: form now/date
>> reduce/only [b: button red (form now/date)] [button]
== [b: button 255.0.0 (form now/date)]


although at least the last case gets most of the way there. What 
I'd really like is:

>> reduce/ignore [b: button red form now/date]
== [b: button 255.0.0 "25-May-2006"]
Ladislav
25-May-2006
[4730]
I am using my BUILD dialect http://www.fm.tul.cz/~ladislav/rebol/build.r
to do it as follows:

>> build [b: button ins red ins form now/date]
== [b: button 255.0.0 "25-May-2006"]

or, another alternative:


>> build/with [b: button red form now/date] [red: system/words/red 
form: get in system/words 'form]
== [b: button 255.0.0 "25-May-2006"]
Gabriele
25-May-2006
[4731]
Use do/next in the parse rule. (that's the reason I suggested the 
DO command for parse some time ago...)
Ashley
25-May-2006
[4732x2]
Not sure I understand, a small example would help. ;)
Or was your comment intended for Ladislav?
Cyphre
25-May-2006
[4734]
Ashley: reduce /only -- Only evaluate words and paths, not functions
So the results you are getting above seems logicalto me.
Ashley
25-May-2006
[4735]
I understand what reduce/only is doing, it's just not doing 100% 
of what I want! ;)
Cyphre
25-May-2006
[4736x2]
Ah got it ;-)
I think VID like parser is the way then.
Ashley
25-May-2006
[4738]
Funny, that's what Anton just said in the RebGUI group. ;)
Volker
25-May-2006
[4739x2]
rest: [1 + 2 button 3 + 4] 
out: copy [] 
while [not tail? rest] [
    either find [button] first rest [
        append out first rest 
        rest: next rest
    ] [
        set [res rest] do/next rest 
        append/only out res
    ]
] 
?? out 
comment "or parse" 
rest: head rest 
out: copy [] 
parse rest [
    any [
        set word ['button] (append out :word) 
        | rest: skip (
            set [res rest] do/next rest 
            append/only out :res
        ) :rest
    ]
]
That trick should help with rebgui too.
Gabriele
25-May-2006
[4741]
Ashley, the idea is that in parse, when you get to something you 
want to evaluate, you set a marker and use do/next. like in volker's 
example. my compile-rules provided  a way to do this automatically 
:)
Volker
25-May-2006
[4742]
If you can convince Carl to take that feature please :)
Gabriele
25-May-2006
[4743]
the problem is that it "breaks" the parse logic, because you cannot 
backtrack a do/next (side effects)
Ashley
25-May-2006
[4744]
Volker/Gabriele: thanks, got it now.
Volker
25-May-2006
[4745x2]
I would left that to the user.
It has its purposes without side-effects. And you can have side-effects 
in the parens too, eg a do/next ;)
Oldes
30-May-2006
[4747x2]
Is there any script for ftp upload of large files?
srcp: open/direct/read src
trgp: open/direct/new/write trg
while [not none? buf: copy/part srcp 1000][
	prin "#"
	insert trgp buf
]
insert trgp crlf
close trgp
close srcp
Anton
30-May-2006
[4749]
Does that work for FTP ?
Oldes
30-May-2006
[4750x4]
yes:-))) the insert trgp crlf is not needed
the trick is, thet there must be the /new switch in the ftp port 
(as at least my ftp server do not support append)
Hm, but now how to make directory thru FTP:(
ah it's easy as well, just using make-dir... I'm reboling so many 
years and still am so suprised how simple it can be:-)
Sunanda
30-May-2006
[4754]
Just be aware that make-dir/deep usually doesn't work with FTP
Henrik
30-May-2006
[4755]
anton has a fix for that
Anton
30-May-2006
[4756x2]
I found that make-dir/deep doesn't work, so I patched FTP OPEN so 
that it creates deep paths as necessary.
This means you no longer have to worry about creating the directory, 
you only need to WRITE your file.
Sunanda
30-May-2006
[4758]
Though you may want to worry about the set-modes for the automatically 
created folders.
Anton
30-May-2006
[4759x3]
http://home.wilddsl.net.au/anton/rebol/patch/ftp-open-new-patch.r
set-modes ? what do you mean ?
You can also use the above patch to only create the path like this:
Sunanda
30-May-2006
[4762]
If you don't explicitly set the file permissions (under UNIX-deriviatives 
mainly) to precisely what you mean them to be, then they *may* be 
set to something other than what you wanted. That applies to all 
files and folders.
http://www.rebol.com/docs/words/wset-modes.html

I'm not suggesting your patch does something wrong.....Just that 
it may not do what someone expects.
Anton
30-May-2006
[4763x2]
port: make port! ftp-spec

port/state/flags: port/state/flags or system/standard/port-flags/open-new
port/handler/open port
Sunanda, good point indeed.
Joe
30-May-2006
[4765]
can anybody provide a simple example to explain copy and copy/deep 
behaviour ? thanks
Sunanda
30-May-2006
[4766x2]
a: 1
b: [2]
c: copy []
append c a
append/only c b
probe c

d1: copy c
d2: copy/deep c
append b 99999
probe d1
probe d2
======
d1 ends up with it's second entry the same as b
d2 ends up with it's second entry a c opy of b's original values
Other explainations here:

http://www.rebol.org/cgi-bin/cgiwrap/rebol/ml-topic-index.r?i=copy
Joe
30-May-2006
[4768]
thanks, good examples