Joining things to form a variable name
Joining things to form a variable name
- Subject: Joining things to form a variable name
- From: Stephen Fitchett <email@hidden>
- Date: Mon, 30 Oct 2000 16:12:38 +1200
I've written a decoder in AppleScript. Unfortunately its size is quite big,
which makes it slow to load/compile in Script Editor (esp. since my
computer is only 25 MhZ). One part of the script I'm trying to decrease in
size is setting 26 properties for 26 letters. I've got properties for each
letter (lettera, letterb...). I'm trying to set up a repeat loop something
like this:
set setLetter to "a"
repeat with i from 1 to 26
set letterQuestion to display dialog {"What character would " & setLetter &
" decode to?"} default answer {"letter" & setLetter} --trying to combine
things to form the name of a property for the default answer- this doesn't
work of course
set {"letter" & setLetter} to text returned of letterQuestion --sets the
property, again I can't join them
configureLetter(setLetter) --specifies which letter is being set and puts
it as setLetter
end repeat
on configureLetter(setLetter)
if setLetter = "a" then
set setLetter to "b"
else if setLetter = "b" then
set setLetter to "c"
else if setLetter = "c" then
set setLetter to "d"
else if setLetter = "d" then
set setLetter to "e"
--and so on
end if
end configureLetter
I know why it won't work, I just can't figure out how to make it work.
Instead at the moment I have:
set letterQuestion to display dialog {"What character would a decode to?"}
default answer lettera
set lettera to text returned of letterQuestion
set letterQuestion to display dialog {"What character would b decode to?"}
default answer lettera
set lettera to text returned of letterQuestion
And so on for every letter.
Any ideas (Remember I've only got AS v1.1)?
-------------------------------------------------------------------------
BCNUL8R,
Stephen Fitchett
"Having children is hereditary; If your parents didn't have any, then you
probably won't either"
-------------------------------------------------------------------------