Computer Science Canada having big time problems with procedurees |
Author: | leafs911 [ Fri Jan 11, 2008 11:35 pm ] |
Post subject: | having big time problems with procedurees |
i am trying to execute procedures with keyboard input and click input (i am using a gui) the problem i am having is that the buttons work fine but the keyboard input is not being recognized. i have checked and made sure that the the part of the code which get the input from the keboard and then give the corresponding output is correct (i took it out and ran it alone without the buttons\gui part. can someone please correct me? thanks Quote: % The Car controller.
import GUI View.Set ("graphics:360;200,nobuttonbar") var chars : array char of boolean procedure Left locate (10, 5) put "Left" parallelput (1) end Left cls procedure Right locate (10, 5) put "Right" parallelput (2) end Right cls procedure Forward locate (10, 5) put "Forward" parallelput (4) end Forward cls procedure Back locate (10, 5) put "Back" parallelput (8) end Back procedure Exit GUI.Quit loop exit when GUI.ProcessEvent end loop Window.Hide (defWinID) end Exit loop var bl : int := GUI.CreateButton (10, 155, 100, "Left", Left) var bf : int := GUI.CreateButton (130, 170, 100, "Forward", Forward) var br : int := GUI.CreateButton (250, 155, 100, "Right", Right) var bb : int := GUI.CreateButton (130, 140, 100, "Back", Back) var bcw : int := GUI.CreateButton (130, 10, 100, "Exit", Exit) loop exit when GUI.ProcessEvent end loop loop Input.KeyDown (chars) locate (4, 1) if chars (KEY_UP_ARROW) then Forward end if if chars (KEY_RIGHT_ARROW) then Right end if if chars (KEY_LEFT_ARROW) then Left end if if chars (KEY_DOWN_ARROW) then Back end if end loop end loop |
Author: | Tony [ Fri Jan 11, 2008 11:43 pm ] | ||
Post subject: | RE:having big time problems with procedurees | ||
there is a clear lack of understanding of how the loops work in that code. If you can answer this question, then the solution to your question will be clear. Consider the following code
When will "Now!" be printed to screen? |
Author: | leafs911 [ Sat Jan 12, 2008 12:03 am ] |
Post subject: | RE:having big time problems with procedurees |
well never cause the processor is processing the loop which it wont get get out of. thanks for tip...i am ganna go look into it right now |
Author: | leafs911 [ Sat Jan 12, 2008 12:38 am ] | ||
Post subject: | Re: having big time problems with procedurees | ||
i did it! thanks to Tony! here is the code that works
|
Author: | Tony [ Sat Jan 12, 2008 1:05 am ] |
Post subject: | Re: having big time problems with procedurees |
well done ![]() Also -- if you wrap your code in [syntax="turing"][/syntax] tags, rather than [quote], it will look much nicer ![]() |