Strange behavior for dirs and files
[1/7] from: robert:muench:robertmuench at: 22-Feb-2003 17:00
Hi, I have the following code snippet which is part of an IOS (link-app)
Reblet:
?? this-folder
;read in current directory
cd: read this-folder
?? cd
; filter out all directories
dirs: make block! []
foreach entry cd [probe reduce [entry type? entry dir? entry file?
entry] if dir? entry [append dirs entry]]
?? dirs
And this is what I get on the command line:
this-folder: %documents/
cd: [%akquise/ %claranet/ %graphics/ %intern/ %jour-fix/ %jourfixe-03/
%knowledge-pool/ %logos/ %marketing/ %organisa
tion/ %personal/ %pr/ %profile/ %rebol/ %vertr=E4ge/ %vorlagen/
%weiterbildung/]
[%akquise/ file! false true]
[%claranet/ file! false true]
[%graphics/ file! false true]
[%intern/ file! false true]
[%jour-fix/ file! false true]
[%jourfixe-03/ file! false true]
[%knowledge-pool/ file! false true]
[%logos/ file! false true]
[%marketing/ file! false true]
[%organisation/ file! false true]
[%personal/ file! false true]
[%pr/ file! false true]
[%profile/ file! false true]
[%rebol/ file! false true]
[%vertr=E4ge/ file! false true]
[%vorlagen/ file! false true]
[%weiterbildung/ file! false true]
dirs: []
Why does dir? Return false for all entries? I really don't have a clue
what's up. Robert
[2/7] from: greggirwin:mindspring at: 22-Feb-2003 11:16
Hi Robert,
RMM> Hi, I have the following code snippet which is part of an IOS (link-app)
RMM> Reblet:
RMM> ;read in current directory
RMM> cd: read this-folder
RMM> ; filter out all directories
RMM> dirs: make block! []
RMM> foreach entry cd [probe reduce [entry type? entry dir? entry file?
RMM> entry] if dir? entry [append dirs entry]]
RMM> ?? dirs
RMM> Why does dir? Return false for all entries? I really don't have a clue
RMM> what's up.
Is %documents/ the current directory (i.e. what WHAT-DIR returns)? If
not, that would explain it I think. If you don't have a fully
qualified path for a file, REBOL uses the current directory when
checking things.
-- Gregg
[3/7] from: robert:muench:robertmuench at: 22-Feb-2003 20:31
> -----Original Message-----
> From: [rebol-bounce--rebol--com] [mailto:[rebol-bounce--rebol--com]]
<<quoted lines omitted: 4>>
> Is %documents/ the current directory (i.e. what WHAT-DIR
> returns)? If not, that would explain it I think.
Hi Gregg, ah I haven't checked this because I though the dir? Function
just checks if the last char is a / and doesn't perform
check-against-hard-disk.
> If you don't have a fully qualified path for a file, REBOL uses the
> current directory when checking things.
Ok, I check it. Thanks for the tip. Robert
[4/7] from: antonr:iinet:au at: 23-Feb-2003 14:03
Gregg is right,
dir? needs to be able to find the path
from wherever the current directory is.
In this situation I usually just use
foreach file read %. [if slash = last file [print file]]
Anton.
[5/7] from: robert::muench::robertmuench::de at: 23-Feb-2003 7:51
> -----Original Message-----
> From: [rebol-bounce--rebol--com] [mailto:[rebol-bounce--rebol--com]]
<<quoted lines omitted: 4>>
> Gregg is right, dir? needs to be able to find the path
> from wherever the current directory is.
Hi, it's always amazing that I'm still learning new things about Rebol
:-))
> In this situation I usually just use
>
> foreach file read %. [if slash = last file [print file]]
And here is a new feature for me: slash (and backslash) are predefined
words. Very interesting. Seems that I have to look at the Rebol
dictonary more regulary. Robert
[6/7] from: antonr:iinet:au at: 23-Feb-2003 22:49
Here's all the predefined characters:
foreach word first system/words [
attempt [
if char? get in system/words word [
print [
mold get in system/words word
tab word
]
]
]
]
#"^[" escape
#"^-" tab
#"^/" newline
#"^L" newpage
#"/" slash
#"\" backslash
#"^M" cr
#"^/" lf ; <- in the new Core beta
Anton.
[7/7] from: greggirwin:mindspring at: 23-Feb-2003 11:01
Hi Anton,
A> Here's all the predefined characters:
You could also do:
>> help char!
Found these words:
backslash char! #"\"
cr char! #"^M"
escape char! #"^["
newline char! #"^/"
newpage char! #"^L"
slash char! #"/"
tab char! #"^-"
-- Gregg
Notes
- Quoted lines have been omitted from some messages.
View the message alone to see the lines that have been omitted