
-----------------------------------
smit9192
Sun Jan 28, 2007 5:02 pm

LOOP help!
-----------------------------------
hi guys

i REALLY need HELP!!!! ASAP in ending LOOP

i have created a power bar ---
a box constantly goes left to right and then left to right again (infinetly)

i want it to stop when i press "y" / any other key (doesnt really matter)


HOW DO I GO ABOUT DOING IT!?!?!?!?!?!?
i would really appriciate ur time and help

this is currently my program:

%Powerbar
var a:int:=55
var aa:int:=65

Draw.Line (50,25,750,25,black)
loop
Draw.FillBox (a,15,aa,35,green)
a:=a+10
aa:=aa+10
delay (10)
if aa>=750 then
Draw.FillBox (0,0,800,40,white)
Draw.Line (50,25,750,25,black)
a:=55
aa:=65
end if

end loop

-----------------------------------
CodeMonkey2000
Sun Jan 28, 2007 5:07 pm

RE:LOOP help!
-----------------------------------
Look up input.keydown. And please use code tas.

-----------------------------------
smit9192
Sun Jan 28, 2007 6:46 pm

Re: LOOP help!
-----------------------------------
OH.. i will def. check it out THANK YOU spearmonkey2000

-----------------------------------
zedx_26
Mon Jan 29, 2007 3:59 pm

RE:LOOP help!
-----------------------------------
if you think then all you have to do is exit loop when some one presses any key so, try this.

code:
if hasch then
exit 
end if

put this code in your program any where

-----------------------------------
Bored
Mon Jan 29, 2007 6:22 pm

Re: LOOP help!
-----------------------------------

if you think then all you have to do is exit loop when some one presses any key so, try this.

code
if hasch then
exit 
end if

put this code in your program any where


That can be reduced to one line there zedx:
exit when hasch
Aswell generally you would want this placed at the end of the loop, or beginning just incase it causes anything funny to happen.

Also if you would like it to run only on one key, such as 'y', we can add to that code.
exit when hasch and getchar='y'
The reason you need to leave the hasch in there is that if you don't then the computer will run getchar even if no key is pressed, this will cause the program to stop and wait for input whereas if you place the haschh infront it will only evaluate the second half if hasch returns true. That means it will only run getchar when there is already a character waiting, thus not stopping the program. This also means the hasch must be placed before getchar or it will not work.
