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

Username:   Password: 
 RegisterRegister   
 Clearing Lines?
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
FearSonic




PostPosted: Tue Feb 03, 2004 8:36 pm   Post subject: Clearing Lines?

I'm trying to write a program that asks for a bet, then if you put a negative number, it outputs "No negative bets!" and clears the input for the question, and lets you reenter your bet. Is that possible? Here's what I have so far:

code:
    loop
        put ""
        put "How much would you like to bet? $" ..
        get betamt
        if betamt < 0 then
            Draw.Text ("No negative bets!", maxx - 225, maxy-150, font, 34)
        elsif betamt > 0 then
            exit
        end if
    end loop
Sponsor
Sponsor
Sponsor
sponsor
Paul




PostPosted: Tue Feb 03, 2004 8:39 pm   Post subject: (No subject)

code:

var betamt : int
var font := Font.New ("serif:18")
loop
    put ""
    put "How much would you like to bet? $" ..
    get betamt
    if betamt < 0 then
        Draw.Text ("No negative bets!", maxx - 225, maxy - 150, font, 34)
        delay (1000)
        cls
    elsif betamt > 0 then
        exit
    end if
end loop

something like this?
or you can have a " press anykey to continue" if you want.
FearSonic




PostPosted: Tue Feb 03, 2004 8:41 pm   Post subject: (No subject)

Well here's the thing, there's a whole racing program built around this code, and I don't want all of THAT to be cleared, just the ONE line that asks for the bet. Specfically, I want it to ask for bets on the exact same line, just clearing what the user input earlier.
santabruzer




PostPosted: Tue Feb 03, 2004 8:43 pm   Post subject: (No subject)

what about drawing a box ? onthe text?
Paul




PostPosted: Tue Feb 03, 2004 8:44 pm   Post subject: (No subject)

Just use locate then, is that what you want?
code:

var betamt : int
var font := Font.New ("serif:18")
loop
    locate(1,1)
    put "How much would you like to bet? $" ..
    get betamt
    if betamt < 0 then
        Draw.Text ("No negative bets!", maxx - 225, maxy - 150, font, 34)
        delay (1000)
        Draw.Text ("No negative bets!", maxx - 225, maxy - 150, font, white)
    elsif betamt > 0 then
        exit
    end if
end loop
FearSonic




PostPosted: Tue Feb 03, 2004 8:45 pm   Post subject: (No subject)

..I love you.

Simple answer haha! Thanks both of you! Smile
Cervantes




PostPosted: Tue Feb 03, 2004 8:48 pm   Post subject: (No subject)

if your using fonts draw a box, if you're using just plain text (as from a put statement) you can just do this

code:
put "                          "
santabruzer




PostPosted: Tue Feb 03, 2004 8:49 pm   Post subject: (No subject)

can't you like do something with View.UpdateArea as well to update the area and remove the flashyness.. etc. ?

EDIT: Ha ha.. just discovered the truth behind View.UpdateArea... Razz
Sponsor
Sponsor
Sponsor
sponsor
jonos




PostPosted: Tue Feb 03, 2004 8:51 pm   Post subject: (No subject)

you could also have done:

put repeat(" ", length of what had just written)

? is that right
FearSonic




PostPosted: Tue Feb 03, 2004 9:02 pm   Post subject: (No subject)

Well, what I pretty much did was use the

put " "

thing, along with the box to white out the "No negative bets!" text. It seems to work out properly! Thanks guys!
Cervantes




PostPosted: Tue Feb 03, 2004 9:03 pm   Post subject: (No subject)

yes that's right.

code:

var word : string := 'hello"
put repeat (" ", length (word))


Smile
shorthair




PostPosted: Tue Feb 03, 2004 10:02 pm   Post subject: (No subject)

no need for that either , its as simple as


put " " : 50

Very Happy Very Happy you know you like it , sur ethe repeat is nice enough to do it the amout of length , but hell im all about saving code ,
jonos




PostPosted: Tue Feb 03, 2004 10:03 pm   Post subject: (No subject)

im all about making it exact, bring it shorthair Mad (j/k)
shorthair




PostPosted: Tue Feb 03, 2004 10:10 pm   Post subject: (No subject)

wel;l in the case of say your asking a user for their age , i mean by clearing 25 spaces you are being safe , come on who is 9999999999999999999999999 years old , so using ": 25 " there is a good way to use it , basiacally all input should be less than a line , name , age ,address , so you should be safe just using the : command , but in hte case of having multiple things on one line , then your best methd is the repeat function , it can be put to good use , if you want awsome bullet proofing i sugest consulting hte help file for extended variable types ,

"strint "comes in very handy for input and so does " intstr" so if your getting a number and they enter a letter your program wont error out , always asume that the user is stupid , thats how you make good apps,
jonos




PostPosted: Tue Feb 03, 2004 10:12 pm   Post subject: (No subject)

also, always assume that your compsci teacher is stupid, cause they will purposely try to screw everything up just to try to make a point and make sure you idiot proofed your program. that is microsoft has to do, cause more than half of the peoople using microsoft are idiots and might format their harddrive thinking they are deleting a file on the hard drive.
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  [ 15 Posts ]
Jump to:   


Style:  
Search: