Event trapping

 BBS: Inland Empire Archive
Date: 05-30-92 (05:30)             Number: 160
From: PHIL HODGES                  Refer#: 19
  To: MARK BUTLER                   Recvd: NO  
Subj: Event trapping                 Conf: (2) Quik_Bas
MB> On 05-25-92 Phil Hodges wrote to Zack Jones...

MB> PH>    Here's how I do CTRL-BRK, just in case anyone's interested...
  > PH>
  > PH>    DIM OldBrk%(4)
  > PH>    DEF SEG = 0
  > PH>     FOR B = &H6C TO &H6F
  > PH>      OldBrk%(I-&H6C) = PEEK (B)
  >                  ^
  > what is the value of "I"?

    ARGH!!!! That SHOULD read OldBrk%(B-&H6C) = PEEK (B)
   Sorry about that..don't know how that got in there!  And no, it won't
   work in the environment, only in compiled .EXE files.  Though I don't
   know if I would use it very much, since it may not be compatible with
   all systems (like OS/2, etc.)


MB> PH>     NEXT
  > PH>    POKE &H6C, &H53
  > PH>    POKE &H6D, &HFF
  > PH>    POKE &H6E, &H0
  > PH>    POKE &H6F, &HF0
  > PH>    DEF SEG
  > PH>    ' to restore
  > PH>    DEF SEG = 0
  > PH>     FOR B = &H6C TO &H6F
  > PH>      POKE B, OldBrk%(I-&H6C)
  >                          ^
  > I assume the value of "I" is the same here to?

   Yes, the code is the same, only substitute the misplaced I for B!
Just one of those stupid things, I guess!

MB> I didn't see the rest of this thread but I took interest in the above
  > code ...but... couldn't get it to work, at least not in the
  > environment it doesn't. Especially without knowing what "I" equals.

   Like I said above, it will only work in compiled .EXE's....as long as
   you change that 'I' to 'B' like it should've been...   :-&

MB> Anyway... I don't have any other routine for disabling ctrl-brk so
  > what's the fix for the above code? (ya really got my interest now)
  > Like I say, I didn't see the rest of the thread so I don't know if
  > you are looking for some other approach but a ctrl-alt-del trap is
  > not hard using KEY trapping. Try this demo out...

   As a matter of fact, I kind of was, but learned that it's not
possible with the above method (PEEK and POKE), but could be with
KEY...I'll try it out...thanks! And (once again) the above code _will_
work in compiled .EXE files, but not in the environment.

   {code removed for space saving...}

MB> Hope this helps ya out...

   So do I...here, let me share another little piece of code, only this
time CORRECT!


  DEF SEG=64: OUT 97,204
  DEF SEG=64: OUT 97,76  'to re-enable keyboard...though this doesn't
                          seem to affect SLEEP


  Here's one way to check if a printer is on line, without having to use
  ON ERROR GOTO if it's not (this only works with Epson as far as I
  know, but if someone could test it)

  DEF SEG = 64
  A = PEEK(8)+256*PEEK(9)
  B = INP(A+1) AND 248) XOR 72
  IF (B AND 128)<> 128 THEN PRINT "Printer off line."
  IF (B AND 128)= 128 THEN PRINT "Printer on line..."

  This will return the amount of memory installed:

  DEF SEG = 0: MEM% = PEEK(&H413)+(256*PEEK(&H414))
  PRINT MEM%;"K memory installed"




  Well, that control-alt-del trap didn't work, bud...oh well. I had
  faith, too!


  |)
  | hi|

___
 X SLMR 2.1a X No, Scotty. I said "Beam me ABOARD". Not "A BROAD"

--- Maximus 2.00
 * Origin: The Gamorian Vortex Project (1:105/601)
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