
-----------------------------------
FearSonic
Tue Feb 03, 2004 8:36 pm

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:

    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

-----------------------------------
Paul
Tue Feb 03, 2004 8:39 pm


-----------------------------------

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
Tue Feb 03, 2004 8:41 pm


-----------------------------------
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
Tue Feb 03, 2004 8:43 pm


-----------------------------------
what about drawing a box ? onthe text?

-----------------------------------
Paul
Tue Feb 03, 2004 8:44 pm


-----------------------------------
Just use locate then, is that what you want?

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
Tue Feb 03, 2004 8:45 pm


-----------------------------------
..I love you.

Simple answer haha! Thanks both of you! :)

-----------------------------------
Cervantes
Tue Feb 03, 2004 8:48 pm


-----------------------------------
if your using fonts draw a box, if you're using just plain text (as from a put statement) you can just do this

put "                          "

-----------------------------------
santabruzer
Tue Feb 03, 2004 8:49 pm


-----------------------------------
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... :P

-----------------------------------
jonos
Tue Feb 03, 2004 8:51 pm


-----------------------------------
you could also have done:

put repeat(" ", length of what had just written)

? is that right

-----------------------------------
FearSonic
Tue Feb 03, 2004 9:02 pm


-----------------------------------
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
Tue Feb 03, 2004 9:03 pm


-----------------------------------
yes that's right.  


var word : string := 'hello"
put repeat (" ", length (word))

:)

-----------------------------------
shorthair
Tue Feb 03, 2004 10:02 pm


-----------------------------------
no need for that either , its as simple as


put " " : 50

 :D  :D  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
Tue Feb 03, 2004 10:03 pm


-----------------------------------
im all about making it exact, bring it shorthair  :x  (j/k)

-----------------------------------
shorthair
Tue Feb 03, 2004 10:10 pm


-----------------------------------
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
Tue Feb 03, 2004 10:12 pm


-----------------------------------
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.
