Computer Science Canada program 'end loop's before I tell it to |
Author: | Insectoid [ Wed Mar 26, 2008 4:17 pm ] | ||
Post subject: | program 'end loop's before I tell it to | ||
This program is a learning project for me which uses some commands I have figured out for myself which weren't taught in my class yet (gr. 10 computer programming) All problems are explained in the code , beginning in 'ERROR'
|
Author: | Mackie [ Wed Mar 26, 2008 4:23 pm ] | ||
Post subject: | RE:program \'end loop\'s before I tell it to | ||
Ok, all you really need to do is move the 'end if' from after the:
to before the comment '%restart the program.' In it's current state you only get the decision if you were 81. |
Author: | Insectoid [ Wed Mar 26, 2008 4:56 pm ] |
Post subject: | Re: program 'end loop's before I tell it to |
Ah! Thank you! That solved everything! We actually haven't done looping yet in class, it was something I figured out for myself, so I don't know everything yet. I don't even know what 'end if' does, it's only there because turing told me to put it there. My teacher's a dink, actually, he's spent 3 days teaching us what names you can't give to a variable/constant/etc. Thank's for a quick reply! |
Author: | Sean [ Wed Mar 26, 2008 4:59 pm ] |
Post subject: | Re: program 'end loop's before I tell it to |
The end if is to end the if statement that you were using. And any loop questions, or any other general ones, all of us are here to help. |
Author: | Insectoid [ Wed Mar 26, 2008 5:12 pm ] | ||
Post subject: | RE:program \'end loop\'s before I tell it to | ||
Just adjusted it a bit, to show what I learn on my own! added some loops so that it only shows the first 'would you like to play' bit once, then skips every subsequent loop. 10 minutes ago, I had no clue how to do this!
also, the F2 tabbing thing I found out on my own too, after seeing my teacher do it (but I didn't see what button(s) he pressed) |
Author: | Sean [ Wed Mar 26, 2008 5:18 pm ] | ||
Post subject: | Re: program 'end loop's before I tell it to | ||
You don't need the extra loops. It was fine the way you had it before.
|
Author: | Insectoid [ Wed Mar 26, 2008 5:24 pm ] |
Post subject: | RE:program \'end loop\'s before I tell it to |
But that way, after you type 'yes' in the 'restarts program' section (or any other word that isn't 'no') you then had to type it in again in the 'introduction to program' section. ex. 'would you like to play again?' type: yes then : 'would you like to play?' its like playing a game that goes through all the opening credits when you go to the menu *couph*bowman 2*couph* |
Author: | Sean [ Wed Mar 26, 2008 5:27 pm ] |
Post subject: | Re: program 'end loop's before I tell it to |
Do it your way then, I was just removing the extra loops because I felt they weren't needed. If someone accidently continued your program when they wanted to exit, it then allows them to have the second opportunity. |
Author: | Insectoid [ Wed Mar 26, 2008 5:37 pm ] |
Post subject: | RE:program \'end loop\'s before I tell it to |
I se your reasoning, but that is what the little X in the corner of the dialog box is for. This is starting to sound a bit...heated. Don't know why, but it is. |
Author: | Sean [ Wed Mar 26, 2008 5:43 pm ] |
Post subject: | Re: program 'end loop's before I tell it to |
Naw, it wasn't getting heated. If I made it look like it then I am sorry. It's up to you on the way you want to do it. Also, I suggest adding some cls 's into your program to clear away any unnecessary data that is showing after you reset. |
Author: | Insectoid [ Wed Mar 26, 2008 5:47 pm ] |
Post subject: | RE:program \'end loop\'s before I tell it to |
Darn you, you posted while I was editing the thing! anyway, I wasn't bothered, it looked to me like you were getting a bit defensive, maybe thought I was being..you know what, never mind. Anyway, I was going to say (until you rudefully replied to my post while I was editing it) that this is my 'learning program' that will see many frequent updates as I learn more about turing, like now I am about to change the background color, which I just learned how to do. |
Author: | Sean [ Wed Mar 26, 2008 5:48 pm ] |
Post subject: | Re: program 'end loop's before I tell it to |
Use a cls after the colourback so it does the entire screen, not the given text areas that are present on your output. |
Author: | Insectoid [ Wed Mar 26, 2008 5:55 pm ] |
Post subject: | RE:program \'end loop\'s before I tell it to |
Ha! you solved my problem before it even came up! I just going to ask how to fix it! seems it doesn't work if you use drawfillbox as I saw somebody do. Now I just have to wait for my teacher to tell me why you do it that way, because then I can figure more things out! |
Author: | Sean [ Wed Mar 26, 2008 5:57 pm ] |
Post subject: | Re: program 'end loop's before I tell it to |
You can use Draw.FillBox but you have to do it before everything. It works in layers, your put statements would go first, if you had the box, then the box would be over top of what was before it. Doing it before, layers it at the bottom. |
Author: | Mackie [ Wed Mar 26, 2008 5:57 pm ] |
Post subject: | RE:program \'end loop\'s before I tell it to |
The screen is only updated around where the text is . When you clear the screen it is wiped and the full color is shown. |
Author: | Insectoid [ Wed Mar 26, 2008 6:00 pm ] |
Post subject: | RE:program \'end loop\'s before I tell it to |
what, and then the text is printed overtop? don't bother, my teacher will (eventually) explain it. |
Author: | Insectoid [ Wed Mar 26, 2008 6:04 pm ] | ||
Post subject: | RE:program \'end loop\'s before I tell it to | ||
Crap, now it doesn't do the 'message to the user based on age' again. here's what I've got:
|
Author: | Sean [ Wed Mar 26, 2008 6:05 pm ] | ||||
Post subject: | Re: program 'end loop's before I tell it to | ||||
Let me explain this a little more clearer. Take your program..
The cls will erase all the output show when you place it somewhere. If you were to use a Draw.FillBox for the background, you would place it at the very beginning of the program. What you would want is...
The reason to put it at the beginning is because of layering, anything after the box, will go over top of it. If it was at the end, it would be on the top, covering everything else up. |
Author: | Insectoid [ Wed Mar 26, 2008 6:09 pm ] |
Post subject: | RE:program \'end loop\'s before I tell it to |
that doesn't work...I get a white screen. hey, how do you post an example with turing: instead of code:? |
Author: | Sean [ Wed Mar 26, 2008 6:14 pm ] |
Post subject: | Re: program 'end loop's before I tell it to |
[syntax="Turing] then end it with [/syntax] There was an extra end if in my example above, remove that and it might work. But, it should clear the entire screen then go back to your first put statement. |
Author: | Insectoid [ Wed Mar 26, 2008 6:22 pm ] |
Post subject: | RE:program \'end loop\'s before I tell it to |
um, it worked fine until I put color in...your way has no color |
Author: | Insectoid [ Wed Mar 26, 2008 6:25 pm ] |
Post subject: | RE:program \'end loop\'s before I tell it to |
wait, now everything's fine. I must of accidentally deleted something... thanks for trying hey! Im a newbie programmer now! |
Author: | Sean [ Wed Mar 26, 2008 6:30 pm ] |
Post subject: | Re: program 'end loop's before I tell it to |
Alright, glad it worked for you. |
Author: | Insectoid [ Wed Mar 26, 2008 6:39 pm ] |
Post subject: | RE:program \'end loop\'s before I tell it to |
wait, never mind,after some more tests, It only works for some (again) help? |
Author: | Sean [ Wed Mar 26, 2008 6:43 pm ] |
Post subject: | Re: program 'end loop's before I tell it to |
Post your revised copy, and I'll take a look see. |
Author: | Insectoid [ Wed Mar 26, 2008 6:45 pm ] | ||
Post subject: | RE:program \'end loop\'s before I tell it to | ||
|
Author: | Nick [ Wed Mar 26, 2008 6:48 pm ] |
Post subject: | RE:program \'end loop\'s before I tell it to |
get rid of the second internal loop and it should work perfect |
Author: | Sean [ Wed Mar 26, 2008 6:48 pm ] |
Post subject: | Re: program 'end loop's before I tell it to |
Which ones are exactly having the problem, and what are you inputing to have this problem? |
Author: | Tallguy [ Thu Mar 27, 2008 8:33 am ] |
Post subject: | Re: program 'end loop's before I tell it to |
Quote: loop
color (blue) put "This program will show you (inaccuratly)" put "How long you have left to live." % optional start put "would you like to know? (yes or no)" get seeage cls exit when seeage = "yes" end loop i dont even hav to enter 'yes' for the program to start, its not a big deal, but make if the user puts in something other then 'yes' or 'no, put like thats not an option etc.[/quote] Quote: %restart the program.
% ERROR Doesn't seem to work, always reverts to the beginning earse that section, delay it ands let the loop d its thing |
Author: | Insectoid [ Thu Mar 27, 2008 11:25 am ] | ||
Post subject: | RE:program \'end loop\'s before I tell it to | ||
Tallguy, you do have to enter 'yes'. Anything else and it will just refrsh the screen. Also, the 'restart program' section I would like to have, part of my 'learning process' And don't quote my coding, read this: http://compsci.ca/v3/viewtopic.php?t=16370 Nick, without the second loop, it does exactly something I don't want it to do, and it dos not solve the problem I am having. Read all the posts next time, before responding. Othrwise ou are just wasting bandwidth. sean-the issues: These ones show age, but not the message
every subsequent 'elsif' shows the message, but not the age. |
Author: | Mackie [ Thu Mar 27, 2008 11:54 am ] | ||
Post subject: | RE:program \'end loop\'s before I tell it to | ||
Well, for this one, what you have it so a the total needs to be greater than 60 and less than 0, there is no number that meets those criteria. Maybe you meant 'or' rather than 'and'? |
Author: | Sean [ Thu Mar 27, 2008 12:22 pm ] | ||
Post subject: | Re: program 'end loop's before I tell it to | ||
He didn't mean to add an 'and' or an 'or', due to the fact that he already has it checking for an age lower then zero. What he wants to do, is to get rid of the rest of the code, leaving the part checking to see if the Total was higher then 65.
|
Author: | Insectoid [ Thu Mar 27, 2008 2:25 pm ] | ||
Post subject: | RE:program \'end loop\'s before I tell it to | ||
Well, Sean, you fixed one problem... I changed it a bit to this:
I changed it so if you press any button (well, any button that isn't pre-assigned) and enter it will continue to display your message. Is there any way to do it so the user only has to press enter, and not something else first? |
Author: | Sean [ Thu Mar 27, 2008 2:38 pm ] | ||
Post subject: | Re: program 'end loop's before I tell it to | ||
Look up getch for what you want. It will halt the program until a button is pressed. Or you can do this..
But I suggest reading getch before using my idea, since you learn better by doing it yourself. Plus, what I wrote, might not be what you are after. |
Author: | Insectoid [ Thu Mar 27, 2008 2:49 pm ] |
Post subject: | RE:program \'end loop\'s before I tell it to |
no, that isn't what I was after...I don't want it to be optional, just 'hit a button to conitnue' so it pauses to let the user read it, then they can continue the program to see the rest. I don't want to use delay, either |
Author: | Mackie [ Thu Mar 27, 2008 2:54 pm ] | ||
Post subject: | RE:program \'end loop\'s before I tell it to | ||
Perhaps? |
Author: | Insectoid [ Thu Mar 27, 2008 3:06 pm ] |
Post subject: | RE:program \'end loop\'s before I tell it to |
Actually, while reading a different thread, I found something called Input.Pause. It waits for any input, then continues the program! thanks anyway |
Author: | Nick [ Thu Mar 27, 2008 3:10 pm ] |
Post subject: | RE:program \'end loop\'s before I tell it to |
the thign about Input.Pause is that it creates a flashing box where the text cursor is... Mackie's method is great if you want a subtle input pause |
Author: | Insectoid [ Thu Mar 27, 2008 3:21 pm ] |
Post subject: | RE:program \'end loop\'s before I tell it to |
Meh, that's okay, as long as it works! Food for thought: My teacher has not taught any of the following, which I have discovered (with some help from you guys) how to use: looping 'exit when' multiple looping if/then statements Input.Pause randint Well, my teacher does say that I'm the best student he has ever had... |
Author: | DaveAngus [ Fri Mar 28, 2008 11:49 am ] | ||
Post subject: | RE:program \'end loop\'s before I tell it to | ||
Here is your code updated to make it work a bit better
|
Author: | Sean [ Fri Mar 28, 2008 11:53 am ] |
Post subject: | Re: program 'end loop's before I tell it to |
Dave yet again you post a copy of his work, completed by you. That is not what he wants, nor what we wish for you to do. We want him to learn, and not for him to feel the need to rely on others. The thread was answered, so if a Mod can, please lock the thread. Thank you. |
Author: | DaveAngus [ Fri Mar 28, 2008 12:04 pm ] |
Post subject: | RE:program \'end loop\'s before I tell it to |
Sean, no need to be so uptight. Lay back. Relax... Im helping him out. alright? |