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
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
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
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 :)
True ... which is what I'll use if my print using () doesn't do what I want it to do.
Tnx again!
Tom
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
Good suggestion, Barry - hadn't thought about it quite that way.
Thanks!
Tom