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

World: r3wp

[Core] Discuss core issues

Gabriele
8-Jul-2007
[8414]
Petr, I'm not sure what you want. Obviously %c/ is a dir, and obviously 
it is at the root, so you have to access it as %/c/. This is called 
platform independent file paths. It's the same for all platforms.
Pekr
8-Jul-2007
[8415x2]
Brock, I was confused about reading %/ and getting %c/ instead of 
%/c/, that is all. I did not regarded %/ a root, I thought it is 
just a helper, as %. is .... that dot surely is not real part of 
filesystem, is it?
I resolved it for myself by defining root: %/ and joining it with 
the result of the read, works .... new problem for me is how to set 
attributes of copied directory. Not sure why do I receive error. 
It seems like that dir would be locked or so, but not sure why set-modes 
fail. Is set-modes supposed to work with directories?
Graham
8-Jul-2007
[8417x2]
no
I reported this a couple of years ago .. it does not work
Pekr
8-Jul-2007
[8419x2]
ok, thanks a lot ... it is a pity, I don't need it in fact, but found 
that possibility in docs, tried it, and it nicely works for files 
....
and is there a way to create directory not using make-dir, directly 
setting such attributes during creation process, not later?
Gabriele
8-Jul-2007
[8421]
Petr, that dot (%./) *is* part of the filesystem in most filesystems.
Pekr
9-Jul-2007
[8422]
Can I get following solved somehow, without defining globally visible 
word?

report: does [print item]
foreach item [1 2 3][report item]
Sunanda
9-Jul-2007
[8423]
Given 'does is simply a shortcut for 'func, why not:
    report: func [item] [print item]
Pekr
9-Jul-2007
[8424x2]
because I want to have clean interface to my copy-dir source target 
.....
the trouble is, that later on, I dynamically detect new drive. I 
can't know, what letter usb drive maps to. So I do:

forever [

  for each disk difference stored-disks read %/ [copy-dir source target]
]
btiffin
9-Jul-2007
[8426]
foreach item [1 2 3] [do bind second :report 'item] may work
Pekr
9-Jul-2007
[8427x3]
And I somehow wanted to have 'disk available in my copy-dir :-) Well, 
I can easily solve it via drive: disk and use drive global word in 
my copy-dir func. It is just that I was thinking if I can somehow 
magically bind to it :-)
I need it vice versa - bind item in report to foreach item ....
but no problem, I can get it working other way, I was just curious 
...
btiffin
9-Jul-2007
[8430x2]
That will bind report and item to the local foreach item.
Well actually it binds print and item  to the local item.
Pekr
9-Jul-2007
[8432]
ah .... I tried to look at it from the perspective of report function, 
and was stuck ....
btiffin
9-Jul-2007
[8433]
Yeah bind is a little ummm, magically delicious.
Pekr
9-Jul-2007
[8434]
I have weak USB port, and my flash disconnects from time to time. 
I am testing my copy-dir small script, and during disconnection it 
failed. I had following code there:

attempt [
  data: read/binary source
  write/binary target data
]


Shouldn't attempt catch the error, even if I am in the middle of 
copying of file?
btiffin
9-Jul-2007
[8435x2]
imho.  yes it should.
I've been a little curious about attempt...
if not error? set/any 'value try :value [get/any 'value]

Are there any conditions where the [get/any 'value] could fail and 
as it is outside the try cause an interpreter error trap?  I don't 
know.
Ladislav
9-Jul-2007
[8437]
Pekr: "because I want to have clean interface to my copy-dir source 
target" - I may be dense, but what is "unclean" there?
Pekr
9-Jul-2007
[8438x2]
got to go, but I don't want to send another parameter (drive letter) 
to the function ...
So what I did was, that I defined one word inside foreach loop, which 
will be accessible from other place. It if sufficient, but what is 
"unclean" about it is, that I somehow start to think, that more strict 
way of defining variables is better than globals "floating around" 
:-)
Gabriele
9-Jul-2007
[8440x3]
petr, why is not the disk in the source argument?
inside foreach and accessible somewhere else == global. the proper 
way to do it is a function argument. you can bind, but that does 
not seem clean to me (argument is clean).
and to me it looks like you have the argument already.
Pekr
10-Jul-2007
[8443]
'attempt seems not to be able to catch file reading error. What am 
I doing wrong? Should I use if not error? try [] instead?
Rebolek
10-Jul-2007
[8444]
What do you mean Pekr, it seems OK to me:
>> attempt [read %no-file]
== none
Pekr
10-Jul-2007
[8445]
Rebolek - well, try to attempt [data: read/binary %some-larger-file] 
.... unplug your usb flash when file is being read ....
Rebolek
10-Jul-2007
[8446]
Then buffer the reading.
Pekr
10-Jul-2007
[8447]
yes, I know I could do that, but why read, as a native, is not catched 
when inside of attempt?
Louis
10-Jul-2007
[8448]
Does anyone remember the command for converting a binary file to 
a string so it can be sent by email?
Pekr
10-Jul-2007
[8449x3]
enbase/base?
read/binary should be ok ....
or just - why to care? use send/attach ...
Louis
10-Jul-2007
[8452x2]
Pekr, enbase/base is not what I had in mind. It was a special command 
that did not need a refinement, if I recall correctly.
I'm wanting to send a bunch of huge files to my son. I used this 
command awhile back to convert the files to text, then used compress 
to greatly shrink their size. Unfortunately I accidentally erased 
the source file for my script, and now can't remember the name of 
the command.
Graham
10-Jul-2007
[8454]
compress creates a binary file
Louis
10-Jul-2007
[8455x2]
Graham, sorry for the delay in communucating. The electricity went 
off here, and with it the Internet.
What I want to do in convert a binary file to a string.
Jerry
10-Jul-2007
[8457]
>> blk: [ delete none ]
== [delete none]
>> type? blk/1
== word!
>> type? blk/2
== word!  
;
; none is not of the none! type, unless it's been evaluated. 
; none is so-called indirect value in the REBOL/CORE doc at
; http://www.rebol.com/docs/core23/rebolcore-4.html
;
; In http://www.rebol.net/r3blogs/0034.html, 
; there is a so-called "Scant Evaluation"
;
>> obj: construct [ n: none d: delete ]
>> type? obj/d
== word!
>> type? obj/n
== none! 
; 
; WHY obj/n IS NOT OF THE WORD! TYPE ???
; The "Scant Evaluation" should not evaluate none here.
Louis
10-Jul-2007
[8458]
in headers (and in the construct function) both word lookup and function 
evaluation are disabled, but set-word (assignment) is not.
Jerry
10-Jul-2007
[8459]
Louis, I knew that. My question is ... why none (a word!, not a none!) 
is evaluated in this case. It should not. Notice that none is a word!. 
it has to be evaluated to become a none! That's why Carl called it 
"indirec value" in the REBOL/Core doc.
Louis
10-Jul-2007
[8460x2]
I see what you mean. The actuality seems to contradict those documents.

>> obj: construct [ n: none d: delete ]
>> probe obj
make object! [
    n: none
    d: 'delete
]


It seems that only potentially dangerous evaluation is prevented, 
and not all evaluation.


Scant Evaluation: A minimal form of evaluation used for headers and 
other data blocks that do not allow any level of deep evaluation.
  Perhaps the evaluation of none is not considered "deep."
Pekr, this is what I was looking for (I think): http://www.rebol.net/cookbook/recipes/0048.html


This seems to be related to what you were trying to tell me and I 
just didn't realize it.  Anyway thanks for your help!
Graham
10-Jul-2007
[8462x2]
http://www.rebol.net/cookbook/recipes/0026.html


This recipe says that a binary file is being sent.  I wonder how 
this works because the content type is url encoded, but there is 
not url encode function as a mezzanine by default.
And i don't think that rebol supports octet stream as content type.