Re: Joining things to form a variable name
Re: Joining things to form a variable name
- Subject: Re: Joining things to form a variable name
- From: Greg Strange <email@hidden>
- Date: Mon, 30 Oct 2000 02:26:08 -0600
on 10/29/00 10:12 PM, Stephen Fitchett at email@hidden wrote:
>
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
This is because you are trying to set something which is being returned to
you. try:
set newSetLetter to "letter" & setLetter
configure(newSetLetter)
This worked for me.
>
>
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 got this (in modified form) from Arthur Knapp for another project.
set startLetter to "g"
set charArray to "abcdefghijklmnopqrstuvwxyz"
set charOffset to the offset of startLetter in charArray
set setLetter to character (charOffset + 1) of charArray
Hope this helps.
Greg Strange
--
...[Zeus] has led us on to know,
that Helmsman lays it down as law
that we must suffer, suffer into truth.
-Aeschylus, Agamemnon