[REBOL] Re: need help with comparison operator <> evaluation
From: tomc:darkwing:uoregon at: 14-Nov-2003 9:08
Howdy,
On Sat, 15 Nov 2003, Steve Vondrasek wrote:
> Greetings,
>
> It seems like I always have the hardest time trying to do the simplest things.
For instance in the code snipet below the not equal comparison EXTENSION-IN <> ".txt"
always evaluates to true and always appends ".txt" to the end of the string even if there's
already .txt at the end of the string. I don't understand. Thanks in advance.
>
> INPUT-FILE: ask "Enter name of file with numbers to be processed: " comment { user
enters owwnumbers.txt }
> OUTPUT-FILE: ask "Enter name of output file: "
> INPUT-FILE: make string! INPUT-FILE
> OUTPUT-FILE: make string! OUTPUT-FILE
> comment { Are the last 4 chars of the str equal to ".txt"? If not append ".txt" to
the end of the string. }
> EXTENSION-IN: substr INPUT-FILE ( (length? INPUT-FILE ) - 3) 4
> print EXTENSION-IN comment { prints out .txt on the screen}
> EXTENSION-OUT: substr OUTPUT-FILE ( (length? OUTPUT-FILE ) - 3) 4
> if [EXTENSION-IN <> ".txt"] [append INPUT-FILE ".txt" ]
thing is, the condition in a block is of type block!
and block! is not 'false or 'none so the 'if is 'true.
i.e.
>> type? [false]
== block!