Re: Help!

 BBS: Inland Empire Archive
Date: 04-27-92 (21:19)             Number: 130
From: BOB PERKINS                  Refer#: 121
  To: JOHN GALLAS                   Recvd: NO  
Subj: Re: Help!                      Conf: (2) Quik_Bas
 JG> say I open the CONS: for output as #1.  I print #1,"TEXT".
 JG>  (all this is after a CLS)  Is there a way that I can find
 JG> out that the next text is going to come out at 1(Y), 5(X)?

  You can use interrupt calls to get the cursor position.  Here's an example
of calls to set cursor position and to get the cursor
position using interrupt &h10.  You must start qb with "/l"
to load qb.qlb for it to operate in the environment.  If
you link from the command line be sure and add qb.lib or
you'll get errors.  Since these routines use 0-based screen
position values, the subs adjust row% and column% to make
them work the same as LOCATE.  Page% is the video page you
want to use.  The setcursor sub could also be set up to
return the cursor start and stop scan lines (They're
returned in CX).

  '$INCLUDE: 'qb.bi'
  DECLARE SUB setcursor (row%, column%, page%)
  DECLARE SUB getcursor (row%, column%, page%)
  CLS : LOCATE , , 1, 6, 7
  OPEN "cons:" FOR OUTPUT AS #1
  PRINT #1, "1234567890";
  getcursor row%, column%, 0         'correctly shows you at column 11
  PRINT #1, "": PRINT #1, column%
  setcursor 10, 40, 0
  PRINT #1, "Here!";
  DO: a$ = INKEY$: LOOP UNTIL LEN(a$)
  END

  SUB getcursor (row%, column%, page%)
    DIM regs AS regtype
    regs.ax = &H300
    regs.bx = page% * 256
    interrupt &H10, regs, regs
    row% = (regs.dx AND &HFF00) \ 256
    column% = regs.dx AND &HFF
    row% = row% + 1
    column% = column% + 1     'keep bounds 1-based instead of 0.
  END SUB

  SUB setcursor (row%, column%, page%)
    DIM regs AS regtype
    row% = row% - 1: column% = column% - 1  'to keep bounds 1-based
    regs.ax = &H200
    regs.bx = page% * 256
    regs.dx = (row% * 256) + column%
    interrupt &H10, regs, regs
  END SUB


--- Msg V4.5
 * Origin: Reciprocity Failure  (1:124/4115.236)
Outer Court
Echo Basic Postings

Books at Amazon:

Back to BASIC: The History, Corruption, and Future of the Language

Hackers: Heroes of the Computer Revolution (including Tiny BASIC)

Go to: The Story of the Math Majors, Bridge Players, Engineers, Chess Wizards, Scientists and Iconoclasts who were the Hero Programmers of the Software Revolution

The Advent of the Algorithm: The Idea that Rules the World

Moths in the Machine: The Power and Perils of Programming

Mastering Visual Basic .NET