>From: [EMAIL PROTECTED]
>This function works fine, however, is there a word
>already defined in rebol 2.3 (or 2.2)  that does this already?
>
>Or is there a better way to do this?
>I developed the tword function to test for the presence of
>words in a template database so that I don't get
>path errors trying to access a word in a block that doesn't exist?

You don't need this function at all, just use
  if select ablock :aword [ actually lookup aword ]

if treats anything except false or none as being true, so the return from 
select is adequete on its own..
Hope this helps,

   Cal Dixon ([EMAIL PROTECTED])
-><-


>
>Useful for testing words in databases like the example
>in chapter 5 http://www.rebolpress.com/rog/chapter5.html
>
>rebol[]
>
>tword: func [
>    "Test to see if word/string is found in block."
>    ablock [block!] "The block to test."
>    aword  [word!]  "Test to see if this 'word is found in block."
>][
>    not (none? select ablock :aword)
>]
>
>
> >> tword [this "thing" that "thing" ] 'that
>== true
>
> >> tword [this "thing" that "thing" ] 'any-thing
>== false
> >>
>
> >> x: [this "thing" that "thing" ]
>== [this "thing" that "thing"]
> >> print x/this
>thing
> >> print x/that
>thing
>
>Using func tword I can test 'any-thing first to see if it exists
>so I don't get a dumb error like this:
>
> >> print x/any-thing
>** Script Error: Invalid path value: any-thing.
>** Where: print x/any-thing
>
>Any other ideas? A better way to do this with a native word?
>
> >>Douglas Vos - EDS/GM-BSU Webmaster
>e-Mail: mailto:[EMAIL PROTECTED]
>

________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com

Reply via email to