Understanding Data Types
[1/6] from: learned::talentsinc::net at: 7-Jun-2001 16:55
I am a newbie to REBOL and trying to get a grip on it's data typing. My
question concerns the following scenario:
If I read a directory:
foo: read %.
how can I execute a find against the block? If I try:
find foo "a.txt"
I get a null response, as I do with most other variations. I know that each
entry in foo is considered a file type, and I am assuming that is why my
find doesn't work, but what do I need to do to make it work?
Thanks
Ed
[2/6] from: brett:codeconscious at: 8-Jun-2001 8:39
Hi Ed,
foo: read %. returns a block of files. So you need to search using a file.
find foo %a.txt
or
find foo to-file "a.txt"
Brett.
[3/6] from: gjones05:mail:orion at: 7-Jun-2001 17:53
From: "Gary Learned"
> I am a newbie to REBOL and trying to get a grip on it's data typing. My
> question concerns the following scenario:
<<quoted lines omitted: 5>>
> entry in foo is considered a file type, and I am assuming that is why my
> find doesn't work, but what do I need to do to make it work?
Hi, Ed,
You are almost there. You are correct about the entries in foo. What is not
correct is the value you were using to search. "a.txt" is a string. You need a
file type also here.
find foo %a.txt
should do the trick (assuming a.txt is in the directory! ;-). Next thing you
may be surprised about is that find returns the series at the point of the
match. So you may still get a series. To only get the single value, use
'first.
find [1 2 3 4 5] 3 ;returns== [3 4 5]
first find [1 2 3 4 5] 3 ;returns ==3
a: first find [1 2 3 4 5] 3 ;returns ==3 and a now refers to the value.
Hope this helps. REBOL is a great language. Ask all the questions that you
want.
--Scott Jones
[4/6] from: learned:talentsinc at: 7-Jun-2001 21:08
I'm pretty sure I tried that, but I'll try it again and let you know.
--On Friday, June 08, 2001 8:39 AM +1000 Brett Handley
<[brett--codeconscious--com]> wrote:
[5/6] from: jean:holzammer:faedv-n:bayern at: 8-Jun-2001 7:36
> I am a newbie to REBOL and trying to get a grip on it's data typing. My
> question concerns the following scenario:
<<quoted lines omitted: 3>>
> find foo "a.txt"
> I get a null response, as I do with most other variations. I know that
each
> entry in foo is considered a file type, and I am assuming that is why my
> find doesn't work, but what do I need to do to make it work?
Exactly. The entries in block foo are of type file!.
So try this:
find foo %a.txt
this results in a view to the block foo beginning from the position of
%a.txt in the block.
If you'd like to know , if block foo contains a file %a.txt, do this:
if found? find foo %a.txt
[
print "Entry exists in block"
]
If you just want to know, if file a.txt exists, you can use:
if exists? %a.txt
[
print "file exists"
]
Jean
[6/6] from: cybarite:sympatico:ca at: 7-Jun-2001 18:35
To find a file, try the search for what REBOL thinks is a file %a.txt not a
string "a.txt"
foo: read %.
find foo %a.txt
Notes
- Quoted lines have been omitted from some messages.
View the message alone to see the lines that have been omitted