RE: Go To Commands (AppleScript)
RE: Go To Commands (AppleScript)
- Subject: RE: Go To Commands (AppleScript)
- From: Emmanuel <email@hidden>
- Date: Fri, 19 Jul 2002 00:54:48 +0200
At 7:20 PM +0200 18/7/02, Dave DeLong wrote:
>
>
The game I'm planning to write is a computer version of the calculator game
>
"Drugwars." This game, when programmed on a calculator, absolutely needs
>
gotos. If not, the entire thing would be an incredibly complex if...then
>
statement. Gotos aren't necessarily bad programming if they're managed
>
correctly and written in a way that optimizes performance. Jumping from end
>
to end of code, however, is stupid. I just need jumps for certain areas.
As I understand, AppleScript was designed as a very procedural language. We
must chop our code into numerous small routines, in order to compensate for
the weak branching possibilites of the language. In order words, "return"
is used instead of "next repeat", "goto" etc.
For instance, instead of:
----------------
repeat for ...
blah blah
if something then next repeat
blah blah
end repeat
----------------
you would write:
----------------
on OneLoop()
blah blah
if something then return
blah blah
end OneLoop
repeat for ...
OneLoop()
end repeat
----------------
Now, I would be curious to know whether the procedural suggestion would
work in your case.
Emmanuel
_______________________________________________
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.