Page 1 of 1

LOCATE question

Posted: Fri Aug 25, 2006 4:01 am
by DWolf
Hi all,

I know how to use the basics of the LOCAT Row,Column statement however I have a quick question about it.

I want to print the character "0" on a new line after my last PRINT statement. However due to things previous in the program this line may not always be the same so I can't set the Row and Coumn to a definite position.

So how to I locate the previous PRINT statement and put the character on a new line after that?

NOTE: Due to what I am trying to do here I cannot just use another PRINT Statement as I am creating an animation by making the character move. Thanks for any help.

Posted: Fri Aug 25, 2006 11:16 am
by The Walrus
Look up the CSRLIN and POS functions in the qb help file, they should do the trick. You can use them to determine where on the screen the cursor is.

Posted: Fri Aug 25, 2006 5:55 pm
by DWolf
Well, my code is:

Code: Select all

FOR Counter = 0 TO 60
row = CSRLIN
LOCATE row, 1
PRINT "0"
SLEEP 1
LOCATE row, 1
PRINT " "
LOCATE row, 2
PRINT "0"
NEXT Counter
So you can see I want the 0 to jump back and forth between coulmn 1 and 2. However at the moment when it loops around it just starts a new line (yes I need a loop here). How can I keep it all on the same line?[/code]

Here's one way to do it!

Posted: Sun Aug 27, 2006 4:42 am
by AiRMaN
I think you went coding without any planning at all!, from what I understood, you want to creat a primitive animation of a "0" that jumps between Column 1 and 2, here's the code for it,

Code: Select all

CLS
row = CSRLIN             ' Set 'row' to the current Row location
FOR Counter = 0 TO 60 
LOCATE row, 1            ' Set cursor position to row and column 1 
PRINT "0"                ' Print '0'
SLEEP 1                  ' Wait a sec or a key press
LOCATE row, 1            ' Again locate row and column 1
PRINT " "                ' Erase '0'
LOCATE row, 2            ' Locate row and column 2
PRINT "0"                ' Print '0'
SLEEP 1                       
LOCATE row, 2            ' Locate row and column 2 again
PRINT " "                ' Erase '0'
NEXT Counter
END