Hi T Brownell
you wrote:
>x: none
>cat: "feline"
>cat: "kitty"
>fact: "I have a kitty"
>if found? find fact cat [x: "found it"]
>if found? x [print x]
>unset 'x
A few remarks:
>x: none
this line is not necessary. But it's not a bad idea.
>cat: "feline"
>cat: "kitty"
Now cat evaluates to "kitty" only! cat no longer evaluates to "feline"! If
you try this code against fact: "I have a feline" find will fail!
Given:
>cat: "feline"
>cat: "kitty"
>fact: "I have a kitty"
you could say:
if found? find fact cat [print x: "found it"]
>How can i make the 2 values of cat: into a pattern
>that can be used in this script? Also, the rest of
>this script stinks... THERE MUST BE A BETTER WAY!!!
fact: "I have a kitty"
rule: [
[thru "kitty" (x: "found kitty")] |
[thru "feline" (x: "found feline") ]
to end
]
>> if parse fact rule [print x]
found kitty
fact: "I have a feline"
>> if parse fact rule [print x]
found feline
To identify both in any order:
fact-1: "The feline I have is a kitty."
fact-2: "I have a kitty which is a feline"
one possible approach is:
rule: [
marker: [thru "kitty" (x-kitty: "found kitty")]
:marker [thru "feline" (x-feline: "found feline") ]
to end
]
unset 'x-feline
unset 'x-kitty
if parse fact-1 rule [
if value? 'x-feline [print x-feline]
if value? 'x-kitty [print x-kitty]
]
unset 'x-feline
unset 'x-kitty
if parse fact-2 rule [
if value? 'x-feline [print x-feline]
if value? 'x-kitty [print x-kitty]
]
>> unset 'x-feline
>> unset 'x-kitty
>>
>> if parse fact-1 rule [
[ if value? 'x-feline [print x-feline]
[ if value? 'x-kitty [print x-kitty]
[ ]
found feline
found kitty
>>
>> unset 'x-feline
>> unset 'x-kitty
>>
>> if parse fact-2 rule [
[ if value? 'x-feline [print x-feline]
[ if value? 'x-kitty [print x-kitty]
[ ]
found feline
found kitty
Hope this helps.
;- Elan >> [: - )]