QBasic / QB64 Discussion Forum      Other Subforums, Links and Downloads
 

 Return to Index  

good light status program (imo) for mac, should address issue?

April 6 2005 at 11:25 AM
mennonite  (no login)


Response to Problem with the Scroll Lock

 
'---------------------------------------------------------
'(thanks to jake for the bits in these 9 lines)
'www.jake.dk/programmering/QBASIC/uk/bas_files/keys1.bas
'-----Turn off num-, scroll- and caps lock----------------
'DEF SEG = 64
'POKE 23, PEEK(23) AND 63 'Caps Lock off
'POKE 23, PEEK(23) AND 64 'Num Lock & Scroll Lock off
'DEF SEG
'---------------------------------------------------------

'ok mac, this should take care of you:
'(loved the chat program btw)
'
'what you're looking at is a program that keeps track of the
'scroll and numlock. i ran two windows of this simultanously.
'without focus, it can't read the new state... so you only have
'to Push the button once, but the other program won't figure it
'out until it's window has focus, when it will automatically update.
'the way around this is to have the program copy the status of each
'light in a file the way your chat program does. you could have a file
'called "stat.tmp" and the first byte could be a 1 for N and 2 for S
'and 3 for both and 0 for bothoff. then as long as One of the windows
'has focus (and can read) it can write so the other one picks up the
'data regardless of whether it's in the background or not.

'mennonite

' ini
CLS : GOSUB keylights: GOSUB makescene

DO
q$ = SPACE$(1) + "what this does is just demonstrates that it works while other things are happening"
FOR l = 1 TO LEN(q$)
'go back to old spot
IF cx > 0 AND cy > 0 THEN LOCATE cy, cx
PRINT MID$(q$, l, 1);
'save new spot
cx = POS(0): cy = CSRLIN
'slow then check lights
GOSUB moment: GOSUB keylights
'update only if needed
IF status <> statusb THEN statusb = status: GOSUB makescene
NEXT l
LOOP UNTIL nkey$ = CHR$(27) 'esc quits
CLS
END

keylights:
DEF SEG = 64
state = PEEK(23) AND 63
n = 0: s = 0
SELECT CASE state 'n32 s16
CASE 48
n = 1: s = 1
CASE 32
n = 1
CASE 16
s = 1
END SELECT
'these work but aren't needed for this...
'also you don't want more than one line checking inkey$ (..?)
'nkey$ = LCASE$(INKEY$)
'IF nkey$ = "n" AND n = 1 THEN POKE 23, PEEK(23) XOR &H20 'NUM Lock off
'IF nkey$ = "s" AND s = 1 THEN POKE 23, PEEK(23) XOR &H10 'Scroll Lock off
DEF SEG
status = s * 2 + n * 1
RETURN

makescene:
VIEW PRINT 1 TO 4: : LOCATE 1, 1: PRINT SPACE$(20): PRINT SPACE$(20):
LOCATE 1, 1: IF s = 1 THEN PRINT "hey, scroll's on" ELSE PRINT "scroll's off"
LOCATE 2, 1: IF n = 1 THEN PRINT "hey, numlock's on" ELSE PRINT "numlock's off"
VIEW PRINT 5 TO 15
RETURN

moment:
t = TIMER: DO: IF nkey$ <> CHR$(27) THEN nkey$ = INKEY$
LOOP UNTIL TIMER > t + .01 OR TIMER < t - .1
RETURN



 
 Respond to this message   
Responses

 Copyright © 1999-2014 Network54. All rights reserved.   Terms of Use   Privacy Statement