Thread: Ok one problem
View Single Post
  #2   Spotlight this post!  
Unread 13-02-2003, 00:52
Anthony Kesich's Avatar
Anthony Kesich Anthony Kesich is offline
Programmer Turned Engineer
AKA: SonKenshin
#1097 (Site 3 Engineernig)
Team Role: Leadership
 
Join Date: Jan 2003
Rookie Year: 2003
Location: Sacramento, CA
Posts: 186
Anthony Kesich has a spectacular aura aboutAnthony Kesich has a spectacular aura about
Send a message via AIM to Anthony Kesich
Re: Ok one problem

Quote:
Originally posted by cantwell03
if time < (a certain time) then do_a_turn

do_a_turn:
"turn code"
Here's the problem my friend. No matter what, your code will execute your "turn code." If the if statement is found to be true, it will jump to do_a_turn, if it is found to be false, then it will just keep going and run into the "turn code" so your code is right except for one thing, you need a goto statement between your if/then and your lable. It would look something like this:

Code:
if time < (a certain time) then do_a_turn:
 goto skip_do_a_turn:

do_a_turn:
 "turn code"

skip_do_a_turn:
kinda ugly and confusing, wouldn't you say? so i prefere an alternate meathod of inverting your ifthen statements, which would look like this:

Code:
if time >= (a certain time) then skip_turn:
 "turn code"
skip_turn:
a lot simpler. if you look at it, it does the same as the previous code. In the first one, if the time is greater than the set time, then it would keep going, hit the goto statement, and skip the code. if it were less than, it would jump to the code and preform it. on the seconf one, if it were greater, it would jump to the lable, skipping the "turn code." if it were less than, it would just keep going and preform the turn. Hope this helps.

-Kesich
__________________
C is screwing up my English--I'm ending all my sentences in semi-colons;

Horray for most things! -George Carlin

"Sure, I'll play rugby. Besides, I have a lot of experience running from really big guys who want to cream me." -Me, Freshman year