Oops, it occurs to me that I forgot to add the tail refinement to my first
find (meaning a file feeder~fodder.r~ would be missed for example). This
should work better:
has-backup-file?: func [
{Returns true if any item in block ends with r~}
arg [block!]
][
forall arg [
if (result: find/tail first arg "r~") [
if (length? result) = 2 [
return true
]
]
]
return false
]
Later,
Stephen
On Thu, 7 Sep 2000, S. Sayer wrote:
> This one and the one before won't work as asked because they'll return
> true for files with r~ anywhere in the name. Try this instead (off the top
> of my head):
>
>
> has-backup-file?: func [
> {Returns true if any item in block ends with r~}
> arg [block!]
> ][
> forall arg [
> if (result: find first arg "r~") [
> if (length? result) = 2 [
> return true
> ]
> ]
> ]
> return false
> ]
>
>
>
> On Thu, 7 Sep [EMAIL PROTECTED] wrote:
> >
> > Hi,
> >
> > Or even -
> > test-for-ext: func [
> > "Search a block for items ending with the given string. Returns TRUE or
> > FALSE"
> > value [string!]
> > data [block!]
> > ] [
> > foreach item data [
> > if find/last item value [ return true ]
> > false
> > ]
> > ]
> >
> > cheers, john
> > >
> > I have a block which contains filenames. I would like to get a true or
> > false value back indicating whether or not there is a filename in the block
> > that terminates with a r~ extension.
> >
> > Please show me how to do this.
> >
> > >> a
> > == [%cast.r %feedback.r %ftp.r %ftp.r~ %instinet.r %instinet.r~ %lconfig.r
> > %lconfig.r~ %nntp.r %notes.html %rebdoc.r
> > %rebol.exe %re...
> >
> > Could someone show me how to glob for feedback.r?
> >
> > In other words, I want to say
> >
> >
> > Get your FREE Email and Voicemail at Lycos Communications at
> > http://comm.lycos.com
> >
> >
> >
> >
> >
>
>