this works for me:

INPUT-FILE: ask "enter filename:  "
ext: either ((length? INPUT-FILE) > 3) [
            copy at INPUT-FILE((length? INPUT-FILE) - 3)
        ][
            ""
        ]
print ext
if ext <> ".txt" [INPUT-FILE: append INPUT-FILE ".txt"]
print INPUT-FILE


;------------------------------------------------
or if using more recent version of rebol core(2.5.2 +)
;------------------------------------------------


input-file: ask "enter filename: "
ext: suffix? input-file
print ext
if ext <> %.txt [input-file: append input-file ".txt"]
print input-file



-MAx

> -----Original Message-----
> From: Steve Vondrasek [mailto:[EMAIL PROTECTED]
> Sent: Friday, November 14, 2003 11:06 AM
> To: [EMAIL PROTECTED]
> Subject: [REBOL] need help with comparison operator <> evaluation
> 
> 
> 
> 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" ]
> if  [EXTENSION-OUT <> ".txt"] [append OUTPUT-FILE ".txt" ]
> INPUT-FILE: make file! INPUT-FILE
> OUTPUT-FILE:  make file! OUTPUT-FILE
> 
> DIAL-PEERS-NUMBERS: read/lines INPUT-FILE ...
> 
> ** Access Error: Cannot open /C/Documents and 
> Settings/svondrasek/Desktop/REBOL/owwnumbers.txt.txt
> ** Near: DIAL-PEERS-NUMBERS: read/lines INPUT-FILE
> 
> Steve Vondrasek
> -- 
> ______________________________________________
> Check out the latest SMS services @ http://www.linuxmail.org 
> This allows you to send and receive SMS through your mailbox.
> 
> 
> Powered by Outblaze
> -- 
> To unsubscribe from this list, just send an email to
> [EMAIL PROTECTED] with unsubscribe as the subject.
> 
> 

-- 
To unsubscribe from this list, just send an email to
[EMAIL PROTECTED] with unsubscribe as the subject.

Reply via email to