-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Another way to handle this is to create a custom property on the
buttons and assign those stings to the custom property:
set the myCharacters of button "B1" to "GK"
set the myCharacters of button "B2" to "HK"
etc.
Now you can:
put it into comparator
repeat with i = 1 to the number of buttons on this card
if the myCharacters of button i contains comparator then send mouseUp
to button i
end repeat
(warning: untested code; may require tweaking...)
On Nov 25, 2005, at 4:39 AM, Alex Tweedly wrote:
Ken Ray wrote:
On 11/24/05 8:52 PM, "liamlambert" <[EMAIL PROTECTED]> wrote:
how do I write this in a switch statement or is there a better way
to write it
Well, first of all, I wouldn't name any buttons with numbers - it can
confuse Rev - use something like "B1" or whatever you like. And
secondly, I
would put whatever is in "it" into some other variable so you can
make sure
it doesn't get messed with.
I agree with everything Ken said - but wanted to show a couple more
versions (just to prove Rev always offers many choices of how to solve
something :-)
My solution below uses B1-B12 instead of 1-12, and has put "it" into
tData:
put it into tData
put "JK,AB,JL,JM,GK,HK,IK,GL,HL,IL,GM,HM,IM,HN,IN,GN" into \
tPairs
put "NextTrack,NextTrack,playpause,back,B1,B2,B3,B4,B5," & \
"B6,B7,B8,B9,B10,B11,B12" into tBtns
repeat with x = 1 to the number of items of tPairs
if tData contains (item x of tPairs) then
do "send mouseUp to btn " & quote & (item x of tBtns) & quote
end repeat
For me, it's fatal to use two "parallel" lists like that - sooner or
later, I'll want to add, delete or move one of the entries, and
mis-count in the other list. Also, I find it easier to read and
comprehend if I keep the string I'm matching directly adjacent to the
name of the button, so I'd do something like
put it into tData
put "JK NextTrack,AB NextTrack,JL playpause,JM back" into tPairs
put comma & "GK B1,HK B2,IK B3,GL B4,HL B5,IL B6,GM B7,HM B8" after
tPairs
put comma & "IM B9,HN B10,IN B11,GN B12" after tPairs
repeat for each item X in tPairs
if tData contains (word 1 of X) then
do "send mouseUp to btn " & quote & (word 2 to -1 of X) & quote
end repeat
I might even do ....
put "JK NextTrack," into tPairs
put "AB NextTrack," after tPairs
put "JL playpause," after tPairs
....
put "GN B12" after tPairs
which is kind of long winded, but has the advantage of being very easy
to scan visually later. For similar reasons, I'd consider putting
them in alphabetical order by the "index" string, rather than grouping
by the "effect" button name - more likely to be helpful when I come
back to look at this bit of code in a year's time (depends on where
the "JK", "AB", etc are coming from).
Or, I might put lCommands into a script-local variable and do
(in initialization code)
put "JK NextTrack,AB NextTrack,JL playpause,JM back" into lCommands
put comma & "GK B1,HK B2,IK B3,GL B4,HL B5,IL B6,GM B7,HM B8" after
lCommands
put comma & "IM B9,HN B10,IN B11,GN B12" after lCommands
split lCommands with comma and space
(in running code)
put it into tData
if lCommands[tData] is not empty then
do "send mouseUp to btn " & quote & lCommands[tData] & quote
end if
Which of these I'd choose probably depends, honestly, mostly on the
mood I'm in at the time :-)
I could however probably put together a half-way convincing claim that
the choice would be made according to the likelihood of subsequent
maintenance efforts, and finding the optimum balance between ease of
reading (by programmer) vs conciseness vs speed vs ...
--
Alex Tweedly http://www.tweedly.net
--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.362 / Virus Database: 267.13.4/176 - Release Date:
20/11/2005
_______________________________________________
use-revolution mailing list
[email protected]
Please visit this url to subscribe, unsubscribe and manage your
subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
- -----------------------------------------------------------
Frank D. Engel, Jr. <[EMAIL PROTECTED]>
$ ln -s /usr/share/kjvbible /usr/manual
$ true | cat /usr/manual | grep "John 3:16"
John 3:16 For God so loved the world, that he gave his only begotten
Son, that whosoever believeth in him should not perish, but have
everlasting life.
$
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (Darwin)
iD8DBQFDhyKR7aqtWrR9cZoRAq5oAKCR38AK4YFyROEwgQaUMNn2/K6KbgCcD8ff
B7eB/EycBP55fUSd+keUQaM=
=MBFP
-----END PGP SIGNATURE-----
___________________________________________________________
$0 Web Hosting with up to 200MB web space, 1000 MB Transfer
10 Personalized POP and Web E-mail Accounts, and much more.
Signup at www.doteasy.com
_______________________________________________
use-revolution mailing list
[email protected]
Please visit this url to subscribe, unsubscribe and manage your subscription
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution