Computer Science Canada Menus: How to switch back to a processes undeclared?? |
| Author: | marsbarz [ Mon Apr 04, 2005 9:55 am ] | ||
| Post subject: | Menus: How to switch back to a processes undeclared?? | ||
I'm writing this program for my compsci class, and yes, I'm using processes. I know I read the thread on why processes should be avoided but I think in this case it's not really necessary to put everything into a loop because in the end it'll get me the same amount of marks. BUT here is where I might be wrong! I am actually very new to turing and programming in general and I ran into this little problem while I was writing my program. I used a process to create a menu screen for the program which would run at the start. But now that menu has a selection process which has to be declared before the menu so that the menu can utilize the selection (can't run an undeclared process). But now, there is an option on that menu selection process that is supposed to return the user back to the menu if their selection is invalid. So I'm wondering exactly what I should be doing here? Should I just put everything into a loop somehow (still haven't figured out how I'm going to do that) or is there a method to manipulate the code so I can jump to a process that is otherwise undeclared? Here is the code specific to my problem, pre-declared variables and stuff not included:
Thank you in advance for any help! |
|||
| Author: | Delos [ Mon Apr 04, 2005 10:46 am ] |
| Post subject: | |
First off, you're using Procedures not Processes in your code... And the loop idea sounds good. Try this as your basic method for coding: - think about everything that your code has to do. - anything that can be put into a box, do so (in this case your boxes will be procedures - *very* useful thinggies - stick with them) - keep in mind that in OOT all procs etc used have to be declared before they're used...so basically programme so that the most global procs are made first, followed by more local ones. - in the end, use one final, main, super, simple proc to call all the other ones in the order needed... |
|
| Author: | Cervantes [ Mon Apr 04, 2005 12:55 pm ] | ||
| Post subject: | |||
[quote="Delos"] - keep in mind that in OOT all procs etc used have to be declared before they're used...so basically programme so that the most global procs are made first, followed by more local ones. quote] Declared, yes. But you don't have to have written the entire procedure before you call it. Rather, you can forward the procedure. Best learned by example:
|
|||
| Author: | marsbarz [ Wed Apr 06, 2005 9:52 am ] |
| Post subject: | |
Thank you guys so much for the help, now I see what I should've done. Haha, I always thought proc meant process, re-reading my own post knowing otherwise now makes my own post very annoying to read, lol. Thanks again =) |
|