March 29, 2024, 05:52:03 AM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


Question on locate command

Started by tbohon, November 21, 2007, 11:55:26 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

tbohon

I'm converting an old QB program to CB.  In that program I used a lot of
print tab(xx)

commands.  I can convert these to locate y,x without problems, however I'm not always going to know what line I'm on so getting the 'y' value is problematic.

I tried to use a null value for y and it errored out.

Is there any way to locate the cursor to a specific column on the current line when I don't know what line I'm on?

Tnx.

Tom
"If you lead your life the right way, the karma will take care of itself ... the dreams will come to you."  -- Randy Pausch, PhD (1961-2008)

GWS

November 21, 2007, 01:30:40 PM #1 Last Edit: November 21, 2007, 01:38:23 PM by GWS
Hi Tom,

You can use:

print string$(3,chr$(9)) + "X"

to tab across the screen .. :)

The '3' gives three Tabs, which are chr$(9).

But to move to a particular column needs the locate() statement.  The only thing I can suggest at the moment is keepng a check on which line you are on ..  :)

Graham
Tomorrow may be too late ..

tbohon

Hi, Graham ...

The print statement you suggest will work just fine I think.  I was kind of hoping that there was some way, with the locate() statement, that I could specify the current line but I can work with this.

Thanks!

Tom
"If you lead your life the right way, the karma will take care of itself ... the dreams will come to you."  -- Randy Pausch, PhD (1961-2008)

GWS

Back again Tom,

Of course - there's always another way ..  :)

How about:

locate 5,0
print string$(10," "), "X"


By altering how many spaces you insert, you can get to any column ..

Graham  :)
Tomorrow may be too late ..

tbohon

True ... which is what I'll use if my print using () doesn't do what I want it to do.

Tnx again!

Tom
"If you lead your life the right way, the karma will take care of itself ... the dreams will come to you."  -- Randy Pausch, PhD (1961-2008)

barry

You could always make your own locate routine that works the way you want it to.  It could keep track of the line number so that if you specify a line number it changes and if you use -1 as the line number it uses the current line.

Something like:  (keep in mind I don't know CBasic so I'm inventing this syntax as I type :)


SUB MYLOCATE (L, C)

    IF L <> -1 THEN
        LINE-NUM = L
    END IF

    LOCATE LINE-NUM, C

END SUB


You can initialize LINE-NUM with a valid line number at the start of the program.

Barry

tbohon

Good suggestion, Barry - hadn't thought about it quite that way.

Thanks!

Tom
"If you lead your life the right way, the karma will take care of itself ... the dreams will come to you."  -- Randy Pausch, PhD (1961-2008)