In QDOS/SMSQ/E the 'AT' keyword allows the print statement an
imaginary y/x character cursor location to be used. Is there away of
knowing where this is as a function?
for example:
10 AT 10,20 PRINT "FRED";
20 PRINT LOCX : remark this would return 24
30 PRINT LOCY: remark this would return 20
10 AT 10,20 PRINT "FRED"
20 PRINT LOCX : remark this would return 1 (or 0)
30 PRINT LOCY: remark this would return 11
Thanks
Lee Privett
No direct way in SuperBASIC. However, if you have a function such as
CHAN_W% from the chans_code of DIY Toolkit (Volume C), you can peek
into the Screen Driver Data Block Definition at offset hex 22 (for X)
and hex 24 (for Y). Returns PIXEL coordinates rather than AT
coordinates for the channel number given:
PRINT CHAN_W%(#channel,34) : REMark x coordinate
PRINT CHAN_W%(#channel,36) : REMark y coordinate
As an example, suppose the last AT command in screen channel 1 was AT
1,3. PRINT CHAN_W%(#1,34) would return 18, because it's in pixel
coordinates, not AT coordinates, but rather the values you'd use with
a CURSOR command. To get AT coordinates just divide by the character
width of the current CSIZE, i.e. 6 for CSIZE 0,0, 8 for CSIZE 1,0, 12
for CSIZE 2,0 or 16 for CSIZE 3,0.
Equally, for AT 1,3 we would get a value of 10 with CHAN_W%(#1,36) for
the y coordinate, because in CSIZE x,0 characters are 10 pixels high
or 20 in csize x,1
The character increment (pixels between successive AT locations) is
held in the two words following the x and y positions, so we can write
LocX and LocY functions as shown in this example, which needs the
CHAN_W% extension from the DIY Toolkit volume C:
100 AT 9,3
110 xx = LocX(#1)
120 yy = LocY(#1)
130 CLS #0 : PRINT#0,'#1 cursor is at ';yy;',';xx
140 STOP
150 :
160 DEFine FuNction LocX (channel)
170 LOCal x
180 x = CHAN_W%(#channel,34) DIV CHAN_W%(#channel,38)
190 RETurn x
200 END DEFine LocX
210 :
220 DEFine FuNction LocY (channel)
230 LOCal y
240 y = CHAN_W%(#channel,36) DIV CHAN_W%(#channel,40)
250 RETurn y
260 END DEFine LocY
Sorry, this is a bit complex, the only way I could think of doing this
off the top of my head.
Dilwyn Jones
_______________________________________________
QL-Users Mailing List
http://www.q-v-d.demon.co.uk/smsqe.htm