Addons, still forgot to post them at rot13.org ;-)
Regards, Norman.


example (1) * the quick way *

                                                                                       
            
                  
rot13: func [ char [char! string!] { returns a rotate 13 on alphanumeric charatcers } 
] [
        char: to-char char
        if any [ all [ char >= #"a" char <= #"m" ] all [ char >= #"A" char <= #"M" ] ] 
[ return char
+ 13 ]
        if any [ all [ char >= #"n" char <= #"z" ] all [ char >= #"N" char <= #"Z" ] ] 
[ return char
- 13 ]
        return char
]



example (2) * the lazy way *

str1: "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
str2: "nopqrstuvwxyzabcdefghijklmNOPQRSTUVWXYZABCDEFGHIJKLM"
rot13: func [ char ] [ 
    either found? find str1 char [ return pick str2 index? find/case str1 char ][ 
return char ]
]



example (3) * the long way *

; Define Global variables
ROT13FRSMA: "abcdefghijklmnopqrstuvwxyz"
ROT13TOSMA: "nopqrstuvwxyzabcdefghijklm"
ROT13FRBIG: "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
ROT13TOBIG: "NOPQRSTUVWXYZABCDEFGHIJKLM"
                                            

Rot_13: func[
            "Translate a string to ROT13"
            arg1 [string!] "String to be converted"
            /local encode
        ][
            encode: ""
            while [(length? arg1) > 0][
                either (to-integer first arg1) < 91 [
                    ; We are talking about capitals
                    either attempt [index? find ROT13FRBIG first arg1][
                        encode: join encode pick ROT13TOBIG index? find ROT13FRBIG 
first arg1
                    ][
                        encode: join encode first arg1
                    ]
                ][
                    ; Small letters from here
                    either attempt[index? find ROT13FRSMA first arg1][
                        encode: join encode pick ROT13TOSMA index? find ROT13FRSMA 
first arg1
                    ][
                        encode: join encode first arg1
                    ]
                ]
                arg1: next arg1
            ]
            encode
        ]




-- 
Conversation/lunch: "How do you Eat your Rebol in the Morning?" 






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

Reply via email to