Data Input Editor Part 3

 BBS: Inland Empire Archive
Date: 02-05-93 (03:51)             Number: 399
From: RAYMOND KEITH                Refer#: NONE
  To: ERIC MAYS                     Recvd: NO  
Subj: Data Input Editor Part 3       Conf: (2) Quik_Bas
'This first subroutine I use throughout my program therefore I have
'declared it's variables to be COMMON SHARED. The input editor needs
'Count% and HotKey$ plus you will need several of the mouse related
'variables to support things like a status line help message and to
'determine valid mouse clicks. You make the call, COMMON SHARED or
'passing them back and forth as parameters.

SUB GetButOrKeyPress
  Button1% = 1
  Button2% = 2
  Button3% = 3 'needed to check all three mouse buttons for clicks.
  ButtonChecked% = 0 'Notes which button was clicked
  Status% = 0  'Status of a mouse button
  Count% = 0   'Number of times a button was clicked
  MouseX% = 0  'X coordinate of mouse pointer
  MouseY% = 0  'Y coordinate of mouse pointer
  HotKey$ = "" 'Stores the key press
  IF Count% = 0 THEN
    ButtonChecked% = 1
    CALL ButtonPress(Button1%, Status%, Count%, MouseX%, MouseY%)
  END IF
  'here I check to see if mouse button number 1 has been clicked. At the
  'same time I get the current mouse pointer location. I am using another
  'nifty library routine by Crescent Software. Getting mouse information
  'like this is possible using just QuickBasic. Substitute your mouse
  'code here. Note I only check a mouse button if there hasn't been any
  'new button presses ie Count% = 0
  IF Count% = 0 THEN
    ButtonChecked% = 2
    CALL ButtonPress(Button2%, Status%, Count%, MouseX%, MouseY%)
  END IF
  'Here I check mouse button number two
  IF Count% = 0 THEN
    ButtonChecked% = 3
    CALL ButtonPress(Button3%, Status%, Count%, MouseX%, MouseY%)
  END IF
  'Here I check mouse button three, needed for three button mice.
  HotKey$ = INKEY$
  'This grabs any key press that might be waiting in the keyboard buffer.
END SUB

NOTE: The DrawCursor routine which handles the graphics mode blinking
cursor is 90% Crescent code so I cannot include it here. It's only 12
lines long and not terribly complicated. Obviously you would need to
time the blinks. One other hint is this is where using the XOR comes
in handy. For text mode you don't need this routine anyway. If you
are working in graphics mode for god sakes sell the dog, look under
the couch cushions for loose change or whatever it takes to scrape up
enough money to buy a good graphics library like Crescent's Graphics
Workshop. BTW for the record I don't work for Crescent or sell their
products, I just buy them, use them, and recomend them.

The CALL ShowCursor and CALL HideCursor routines just turn the mouse
pointer on an off. Substitute your mouse code for these.

Raymond

--- DB 1.51/003468
 * Origin: R/E Northwest (1:105/224)
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