Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 if command problems
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
ziki_23




PostPosted: Tue Dec 07, 2010 8:28 pm   Post subject: 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 Confused

Please i need an answer asap
value := parallelget


if value = 88
then
% Parallel Put with the lights
Music.PlayFileStop
delay (2000)
cls
end if
Sponsor
Sponsor
Sponsor
sponsor
andrew.




PostPosted: Tue Dec 07, 2010 10:31 pm   Post subject: 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:
Turing:
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




PostPosted: Wed Dec 08, 2010 12:45 am   Post subject: 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
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
andrew.




PostPosted: Wed Dec 08, 2010 11:29 am   Post subject: 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




PostPosted: Wed Dec 08, 2010 6:53 pm   Post subject: 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 Confused
Tony




PostPosted: Wed Dec 08, 2010 7:07 pm   Post subject: RE:if command problems

The put statements are there just so that _you_ know what is going on in your program.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
andrew.




PostPosted: Wed Dec 08, 2010 7:08 pm   Post subject: 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




PostPosted: Thu Dec 09, 2010 12:53 pm   Post subject: Re: if command problems

hiyaa Cool ... 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



gameshow assignment.t
 Description:
The Game Show Project

Download
 Filename:  gameshow assignment.t
 Filesize:  24.57 KB
 Downloaded:  96 Time(s)

Sponsor
Sponsor
Sponsor
sponsor
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 8 Posts ]
Jump to:   


Style:  
Search: