• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Simple rot-13 encoding script
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Simple rot-13 encoding script


  • Subject: Re: Simple rot-13 encoding script
  • From: Martin Crisp <email@hidden>
  • Date: Wed, 21 May 2003 11:59:09 +1000
  • Organization: Tesseract Computing

On Tue, 20 May 2003 17:27:55 +1000, Ashlin Aronin wrote
(in message <BAF0161B.72D6%email@hidden>):

> Hello all! I made this simple script to encode rot-13, but it isn't
> working. Here's my code:

[snip]

> Can anyone tell me what's wrong?

It's seriously broken. For a start you were setting "AllChars" to
the result of a handler that was only passed a single character,
completely hosing the initial text. What you were trying to achieve
with the TIDs, I'm not sure...

Here's my 2 minute attempt [i.e. not seriously tested]:

on run
set origtext to "This is a test"
set newtext to ""
rot13(text returned of <no-break>
(display dialog "enter the text to rot-13" <no-break>
default answer origtext)) returning newtext
display dialog "Your result:" default answer newtext
end run


on rot13(sometext)
set newtext to ""
repeat with i in sometext
set thenum to ASCII number (i)
if thenum > 64 and thenum < 91 then -- A-Z are ascii 65-90
set letnum to (renum(thenum - 65)) +65
set newtext to {newtext, ASCII character (letnum)} as
string
else if thenum > 96 and thenum < 123 then -- a-z are ascii
97-122
set letnum to (renum(thenum - 97)) + 97
set newtext to {newtext, ASCII character (letnum)} as
string
else
set newtext to (newtext & i) as string
end if
end repeat
return newtext
end rot13

on renum(anum)
return((anum + 13) mod 26)
end renum

rot13("This is a test")
--> "Guvf vf n grfg"
rot13("Guvf vf n grfg")
--> "This is a test"

Have Fun
Martin
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.

References: 
 >Simple rot-13 encoding script (From: Ashlin Aronin <email@hidden>)

  • Prev by Date: Simple rot-13 encoding script
  • Next by Date: Re: Simple rot-13 encoding script
  • Previous by thread: Simple rot-13 encoding script
  • Next by thread: Re: Simple rot-13 encoding script
  • Index(es):
    • Date
    • Thread