Computer Science Canada get statements screwing up my program |
Author: | shlitiouse [ Sun Apr 17, 2005 5:35 pm ] |
Post subject: | get statements screwing up my program |
Alright, I'm working on a painting program. One of the features is that it has boxes on the bottom where the user can click on the box and input a width value or height value. As well as a writting option where the user can input a word and have that word printed on the painting area when they click their mouse. The only problem is, if the user doesn't enter anything and just hits "enter" then the program creates a blank line in that space and moves it down to the next line, continuing to ask the user to enter a value. Does anyone know how I can stop the program from doing this and to just exit the get statement, or to stop it from shifting down a line? If you need an example of the coding I'm using for this, I'll be glad to provide it. |
Author: | Vertico [ Sun Apr 17, 2005 5:56 pm ] | ||
Post subject: | |||
im not sure if this is what u mean.
it would help if there was some code 2 understand what u are talking about |
Author: | Cervantes [ Sun Apr 17, 2005 6:17 pm ] | ||||||||
Post subject: | |||||||||
I don't think it can be done. the get command is not very flexible. You might try using a loop to getch several keystrokes to form your input string yourself.
This isn't error proofed though. If we want an integer for width:
Then it might be useful to make this into a procedure.
You can also do things like deleting characters:
You could take this even further too, and make yourself your very own text box. I made a text box class that is almost completely functional without too much trouble. |
Author: | Martin [ Sun Apr 17, 2005 6:21 pm ] | ||
Post subject: | Re: get statements screwing up my program | ||
shlitiouse wrote: Alright, I'm working on a painting program. One of the features is that it has boxes on the bottom where the user can click on the box and input a width value or height value. As well as a writting option where the user can input a word and have that word printed on the painting area when they click their mouse. The only problem is, if the user doesn't enter anything and just hits "enter" then the program creates a blank line in that space and moves it down to the next line, continuing to ask the user to enter a value. Does anyone know how I can stop the program from doing this and to just exit the get statement, or to stop it from shifting down a line? If you need an example of the coding I'm using for this, I'll be glad to provide it.
The best thing that you could do would be to use getch instead of get (along with noecho) and make your own get function. It would look something like this (in pseudocode)
|
Author: | c0bra54 [ Wed Apr 20, 2005 12:32 am ] |
Post subject: | |
or use the mouse to draw the box, such as (sorry mad hwk need to get done, so only algorithm from me right now:P ) if mousebutton = 1 then record the x and y into arrays, for safe keeping.. and you will eventually run out of oom.. but thats ok ... and yeh just reord them, and then when button = 0 gain record the x and y, and this will give you the box.. how ever you could draw the lines for the outline as you drag ur mouse fairly without problem just use a cls View.Update and a bit of math but yeh, cause having the user enter data... it would work.. but also y not just have the text being entered at the bottom of the screen.. jsut a Q ... if u've ever used AUTO cad.. do it like they do .. the text i mean, sry i couldn't help more.. |