Rebol Talk Forum  |  Getting Started  |  Newbie Help  |  Topic: Path Question
Pages: [1] Print
Author Topic: Path Question  (Read 217 times)
leke
Jr. Member
**
Offline Offline

Posts: 90


View Profile WWW
Path Question
« on: August 31, 2004, 01:45:18 AM »

Hi all,
I am learning about Paths at the moment.

Code:
read %.

which gives me a list of all the files in my REBOL folder.

I wanted to see if I could output only certain types of files, so I tried

Code:
read %.r

and got an error.
How could I do 'wildcard' style searches.

Logged

CarlRead
Full Member
***
Offline Offline

Posts: 105


View Profile
Path Question
« Reply #1 on: August 31, 2004, 02:57:47 AM »

I don't think there's any way to do wildcard searches using READ, but FIND allows them using the /ANY refinement.  So you could use something like this...
Code:
files: read %.
matched: []
foreach file files [if find/any file %*.r [append matched file]]
probe matched
Which would perhaps be best turned into a function...
Code:
dir-find: func [
   "Select files in a directory using a wildcard."
   dir [file!] "Directory path."
   match [file!] "Wildcard.  ie., %*.txt %pic??.jpg"
   /local files matched
][
   files: read dir
   matched: copy []
   foreach file files [if find/any file match [append matched file]]
   matched
]
(Hope that behaves - not extensively tested.)
« Last Edit: August 31, 2004, 02:59:05 AM by CarlRead » Logged

- Carl Read
Pages: [1] Print 
Rebol Talk Forum  |  Getting Started  |  Newbie Help  |  Topic: Path Question
Jump to:  

  
Quick Search...

Advanced search
  
Welcome, Guest. Please login or register.
Did you miss your activation email?
August 28, 2008, 08:37:35 PM
Username: Password: Session Length:
  

News: 01-09-08

Alpha version of REBOL 3 has been released!


  
2231 Posts in 579 Topics by 1733 Members
Latest Member: tea lover gift basket

  Rebol Talk Forum | Powered by SMF 1.0.9.
© 2001-2005, Lewis Media. All Rights Reserved.

RT design by Defiant Pc