
-----------------------------------
ziki_23
Tue Dec 07, 2010 8:28 pm

if command problems
-----------------------------------
I was making a gameshow for a project and i'm running into problems when creating my if command. Im using a parallel port cord. I have four switches and each question has one answer so i want that specifc switch to work so if someone presses a switch the program will know that switch A was pressed which in this case is 88.  but when i hold the switch nothing happens. I made a program that shows the switches are ok. and all switches work. I dont know why, been trying all day :? 

Please i need an answer asap
value := parallelget 


if value  = 88
        then
         % Parallel Put with the lights
    Music.PlayFileStop
    delay (2000)
    cls
end if

-----------------------------------
andrew.
Tue Dec 07, 2010 10:31 pm

RE:if command problems
-----------------------------------
Have you tried pressing and holding the button and then running the program? It's possible that your program is working correctly, but the button isn't pressed at the time of execution (i.e. the program finishes running before the button is pressed).

You could also try putting it in a loop. Something like this:
loop
    if value = 88 then
        put "PRESSED"
    end if
end loop

If you run that, then it will say PRESSED when the button is pressed.

-----------------------------------
Tony
Wed Dec 08, 2010 12:45 am

RE:if command problems
-----------------------------------
@andrew -- there is nothing changing the value of... value, in that loop.
[code]
loop
   value := parallelget
   if value = 88 then
      put "PRESSED"
   else
      put "value is: ", value
   end
end
[/code]

-----------------------------------
andrew.
Wed Dec 08, 2010 11:29 am

RE:if command problems
-----------------------------------
Oh, I didn't know it worked like that. I was just giving him an example to try and figure out what's going on in his program.

-----------------------------------
ziki_23
Wed Dec 08, 2010 6:53 pm

Re: if command problems
-----------------------------------
hiyaa..I still dont under stand because i want it so when value 88 is pushed it goes to the next screen i dont want anything saying it pushed someone becuase i have led for that. so i want it so if i press it, it'll go to the next screen  :?

-----------------------------------
Tony
Wed Dec 08, 2010 7:07 pm

RE:if command problems
-----------------------------------
The put statements are there just so that _you_ know what is going on in your program.

-----------------------------------
andrew.
Wed Dec 08, 2010 7:08 pm

RE:if command problems
-----------------------------------
Yes, we understand that, but before you attempt to make it do that, you have to determine whether it's receiving the value in the first place. By running my code above, you will be able to see whether the computer is receiving 88. If it is, then you can try to make it do something else with some sort of if statement. If not, then you have some other problem. 

Remember, you can't just jump into things sometimes, you have to troubleshoot and figure out what you're program is doing and seeing.

-----------------------------------
ziki_23
Thu Dec 09, 2010 12:53 pm

Re: if command problems
-----------------------------------
hiyaa  8-)  ... I have a troubleshooting program and all 4 switches work correctly. So i dont know whats wrong 


Code:

var value : int
loop
value := parallelget
put value
end loop 

thanks in advance
