Computer Science Canada Need help with running multiple procedures at the same time |
Author: | Raditude [ Thu Jun 10, 2010 8:27 am ] | ||
Post subject: | Need help with running multiple procedures at the same time | ||
What is it you are trying to achieve? Trying to be able to run more then 2 procedures at a time- Basically i have 4 buttons and i want to be able to run the left/right light turn signal at the same time as a headlight or breaklight. What is the problem you are having? Im just not sure how to run more then 2 procedures. I just need an idea on how to run more then 2 lights at the same time. Also, if anybody could tell me how to "toggle" a button, so that i could click a button to turn on, and click it again to turn off, thatd be great. I've attached the picture for the dash as an attachement Describe what you have tried to solve this problem tried calling up different procedures for different buttons, but its just too messy. Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
Please specify what version of Turing you are using 4.1.1 alpha |
Author: | Kharybdis [ Thu Jun 10, 2010 8:43 am ] | ||
Post subject: | Re: Need help with running multiple procedures at the same time | ||
Its possible if you use the fork command in Turing. However, i wouldn't do it this way because it also makes your program unstable. I'd just redo the whole program so you have one 'main' loop, where everything is done. ex.
Your whole problem (including how to 'toggle' a button) can be solved by using boolean statements with the buttons. Set each button to 'false' (a.k.a. not turned on). When they're turned on, keep drawing them until a condition happens where they have to turn off. |
Author: | Cezna [ Thu Jun 10, 2010 12:00 pm ] |
Post subject: | RE:Need help with running multiple procedures at the same time |
You could use processes, but I would highly recommend always trying to avoid processes like the plague unless you are left with no alternatives. You might just have to have the two procedures combined as one. As for the button, are you using widgets? If so, just have it's action change after it is clicked once, or just design the buttons from scratch. If you want, I have a button module I designed that I can post for you to look at. |
Author: | Raditude [ Thu Jun 10, 2010 3:34 pm ] |
Post subject: | Re: RE:Need help with running multiple procedures at the same time |
Cezna @ Thu Jun 10, 2010 12:00 pm wrote: ...
If you want, I have a button module I designed that I can post for you to look at. Could i have a look at that? i think it would help me greatly. Thanks for the help (both of you) |
Author: | Cezna [ Thu Jun 10, 2010 5:08 pm ] |
Post subject: | Re: Need help with running multiple procedures at the same time |
Alright here's my module. There's the module and the program to run it. If you need help understanding any of it, just let me know. Fell free to use it unmodified, but I recommend you make your own button, as the best way to learn is usually to do it yourself. |
Author: | Raditude [ Thu Jun 10, 2010 6:11 pm ] |
Post subject: | Re: Need help with running multiple procedures at the same time |
Cezna @ Thu Jun 10, 2010 5:08 pm wrote: ....
Fell free to use it unmodified, but I recommend you make your own button, as the best way to learn is usually to do it yourself. Thanks! I'm gonna try to make my own, but if i have anymore questions ill ask you. |
Author: | Raditude [ Thu Jun 10, 2010 6:20 pm ] |
Post subject: | Re: Need help with running multiple procedures at the same time |
Uh, question, how do i incorporate the module into the program? Is that a newb question? sorry about that, I've skipped over alot of steps while learning turing. |
Author: | Cezna [ Thu Jun 10, 2010 7:54 pm ] |
Post subject: | RE:Need help with running multiple procedures at the same time |
No, it's not a noob question. Just use the same method I used in the run program. Import the unit at the top of your program, and then all you have t do is use the procedure. You will have to look at the module itself to see what all of the parameters are that are used in the procedure call. |
Author: | InfectedWar [ Thu Jun 10, 2010 8:14 pm ] |
Post subject: | RE:Need help with running multiple procedures at the same time |
You don't need to make more than one procedure run at the same time, you just need to combine all your procedures into one procedure and run it there. Using processes are not a good way to solve your problem, really you should only use processes when your dealing with music or your program is running in different time frames. So it's not recommended to use processes because they are a pain to plan out and to make sure they work properly. |
Author: | Cezna [ Fri Jun 11, 2010 5:18 am ] |
Post subject: | RE:Need help with running multiple procedures at the same time |
That and they will never run predictably, as this is a problem with Turing. |