Re: Go To Commands (AppleScript)
Re: Go To Commands (AppleScript)
- Subject: Re: Go To Commands (AppleScript)
- From: Andy Wylie <email@hidden>
- Date: Sat, 20 Jul 2002 03:23:52 +1200
on 19/7/02 10:54 AM +1200: Emmanuel wrote:
>
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.
>
Is there anything wrong with having the handler call itself?
on OneLoop()
if something then OneLoop()
blah blah
end OneLoop
_____________________________ Andy
_______________________________________________
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.