truble with " * " all characters recognizing
[1/10] from: gduroux::qbiogene::com at: 10-Dec-2002 18:04
I need to open all files in a directory so I tried
Foreach file i/exp/ [if file = %*.tab [do somthing]]
But rebol dont whant to recognise this form
%test.tab is not equal to %*.tab
If some of you could describe me the good way to reach my goal ?
Other question
When I open a file out of the rebol file path I enconter security asking is it a way
to remove it ?
Thanks All
GUILLAUME
[2/10] from: greggirwin:mindspring at: 10-Dec-2002 13:13
Hi Guillaume,
g> I need to open all files in a directory so I tried
g> Foreach file i/exp/ [if file = %*.tab [do somthing]]
g> But rebol dont whant to recognise this form
g> %test.tab is not equal to %*.tab
g> If some of you could describe me the good way to reach my goal ?
This prints all the .r files in the /rebol directory:
Foreach file read %/c/rebol/ [if %.r = suffix? file [print file]]
If you're using an older release, that doesn't have SUFFIX?, here's
the source for it.
>> source suffix?
suffix?: func [
{Return the suffix (ext) of a filename or url, else NONE.}
path [any-string!]
][
if all [
path: find/last path #"."
not find path #"/"
] [to-file path]
]
g> When I open a file out of the rebol file path I enconter security asking is it a way
to remove it ?
You can launch REBOL with the -s command line switch to turn off
security. Type USAGE in the console to see all possible switches.
HTH!
-- Gregg
[3/10] from: al:bri:xtra at: 11-Dec-2002 10:29
Gregg wrote:
> If you're using an older release, that doesn't have SUFFIX?, here's the
source for it.
> >> source suffix?
> suffix?: func [
<<quoted lines omitted: 6>>
> ] [to-file path]
> ]
Here's a slightly smaller version of 'suffix? that I use:
>> source suffix?
suffix?: func [
{Return the extension of a path as a file!, else none.}
Path [file! url!]
][
all [
Path: find/last Path #"."
not find Path #"/"
to-file Path
]
]
I also use 'extension? as an alternative word for this. Like:
extension?: :suffix?
I hope that helps!
Andrew Martin
ICQ: 26227169 http://valley.150m.com/
[4/10] from: rotenca:telvia:it at: 11-Dec-2002 0:30
Hi Andrew and all,
> Here's a slightly smaller version of 'suffix? that I use:
> >> source suffix?
<<quoted lines omitted: 8>>
> ]
> ]
try this:
find/last/match/tail/any x ".*"
four time faster than suffix? on my system.
---
Ciao
Romano
[5/10] from: rotenca:telvia:it at: 11-Dec-2002 2:37
> find/last/match/tail/any x ".*"
Sorry, wrong post. The right routine:
sfx: func [x /local h][parse/all x [some [thru #"."][thru #"/" | h: to end (h:
to file! back h)]] h]
---
Ciao
Romano
[6/10] from: al:bri:xtra at: 11-Dec-2002 15:43
Romano wrote:
> try this:
>
> find/last/match/tail/any x ".*"
>
> four time faster than suffix? on my system.
>> R: func [X] [find/last/match/tail/any X ".*"]
>> r http://Foo.bar/at
== .bar/at
>> suffix? http://Foo.bar/at
== none
Unfortunately, Romano's method fails this test, where a directory has a "."
in it's name. :(
Andrew Martin
ICQ: 26227169 http://valley.150m.com/
[7/10] from: greggirwin:mindspring at: 10-Dec-2002 19:56
Hi Romano,
RPT> Sorry, wrong post. The right routine:
<he he> I figured you knew you were ignoring the no-slash rule, but
I'm glad to know that you make mistakes too. :)
-- Gregg
[8/10] from: al:bri:xtra at: 11-Dec-2002 19:45
Romano wrote:
> Sorry, wrong post. The right routine:
>
> sfx: func [x /local h][parse/all x [some [thru #"."][thru #"/" | h: to end
(h: to file! back h)]] h]
That passes all my tests and is noticably faster over a million iterations,
than the other versions. Here's the version I'm using of Romano's function
using slightly longer words to make it clear.
Extension?: Suffix?: function [File [url! file! string!]] [Ext] [
parse/all File [
some [thru #"."]
[
thru #"/" | Ext: to end (
Ext: to file! back Ext
)
]
]
Ext
]
Thank you, Romano!
Andrew Martin
ICQ: 26227169 http://valley.150m.com/
[9/10] from: al:bri:xtra at: 11-Dec-2002 19:50
Romano wrote:
> Sorry, wrong post. The right routine:
>
> sfx: func [x /local h][parse/all x [some [thru #"."][thru #"/" | h: to end
(h: to file! back h)]] h]
I've also posted this to feedback at:
http://www.rebol.com/feedback.html
Thanks again, Romano!
Andrew Martin
ICQ: 26227169 http://valley.150m.com/
[10/10] from: rotenca:telvia:it at: 11-Dec-2002 16:21
Hi Gregg
> <he he> I figured you knew you were ignoring the no-slash rule, but
> I'm glad to know that you make mistakes too. :)
I make many many errors, but usually i do not post them :-)
---
Ciao
Romano
Notes
- Quoted lines have been omitted from some messages.
View the message alone to see the lines that have been omitted