Num lock on

Please use this Board for QBasic related requests ( file research, programming, etc.)

Moderators:Administrator, Global Moderator

Post Reply
John_Schofield
Full Member
Posts:36
Joined:Tue Mar 18, 2003 3:04 am
Location:Lancashire, UK
Contact:
Num lock on

Post by John_Schofield » Sat Jan 07, 2006 11:54 pm

Hi

Is there a way to ensure that the num lock key effectively stays on throughout a program, even if accidentally pressed? Sort of along the lines of "If num lock turned off, num lock turned on again".

I have a small program which records a sequence of numbers, some of which may have to be typed quickly, and it is all too easy to accidentally catch the num lock key which would then prevent further number entry via the numeric keypad until the problem was spotted.

The program executes a section of code every second using the On Timer function (as it runs a clock as well) so it's possible that the checking routine could be there.

This would have to also work when the program is compiled for distribution to any pc user, including those who may be running XP, as I want to circulate compiled copies once I've finished development, rather than the quickbasic source code..

Any ideas chaps? :?: :?

The only thought I've come up with so far is to drill a hole in the key and put a pin through it once num lock is set!

Valerie
Sr. Member
Posts:54
Joined:Wed Dec 15, 2004 8:10 am
Location:Coromandel, NZ

Post by Valerie » Tue Jan 10, 2006 8:23 am

Test the numlock bit and set it ON if at any time it's turned off accidentally.

John_Schofield
Full Member
Posts:36
Joined:Tue Mar 18, 2003 3:04 am
Location:Lancashire, UK
Contact:

Post by John_Schofield » Tue Jan 10, 2006 9:44 am

Valerie wrote:Test the numlock bit and set it ON if at any time it's turned off accidentally.
How do I do that? Sounds simple but it's one of those things you either know how to do or not!

Valerie
Sr. Member
Posts:54
Joined:Wed Dec 15, 2004 8:10 am
Location:Coromandel, NZ

Numlock coding

Post by Valerie » Wed Jan 11, 2006 10:22 am

The following code checks if the Numlock bit in the Keyboard Data Byte is ON and if not turns it ON. It has been tested in Windows 98se QBasic 4.5 IDE. It has not been compiled & run nor has it been tested in Win.XP.

Code: Select all

DEF SEG = 0
inbyte = PEEK(&H417)  ' Put the byte at &H417 into variable inbyte
IF (inbyte AND 32) THEN       ' Check if the Num-lock bit is ON
   ELSE POKE &H417, PEEK(&H417) OR 32     ' Set Num-lock bit ON
END IF
DEF SEG

Good luck with your projects.

V...

John_Schofield
Full Member
Posts:36
Joined:Tue Mar 18, 2003 3:04 am
Location:Lancashire, UK
Contact:

Post by John_Schofield » Wed Jan 11, 2006 11:03 am

Thanks Valerie. Should be ok for me as I use Win98 and QB4.5.

Testing the compiled version should be simple enough in that environment.

Of course, as XP has "no dos" background this may not work in that OS but all I can do is give it a go!

I'm very grateful for your help

Valerie
Sr. Member
Posts:54
Joined:Wed Dec 15, 2004 8:10 am
Location:Coromandel, NZ

Yes, agree

Post by Valerie » Wed Jan 11, 2006 10:40 pm

Thanks for coming back - lots of posters don't.

Agree that there may be a problem with XP, it has the nasty habit of "hiding" things from non-MS programmers. Sorry, I don't run XP so can't help you with it, I'm strictly not an NT fan..

Cheers again

V...

John_Schofield
Full Member
Posts:36
Joined:Tue Mar 18, 2003 3:04 am
Location:Lancashire, UK
Contact:

Manners

Post by John_Schofield » Thu Jan 12, 2006 12:06 am

Just good manners that's all! Obliged for any assistance.

best wishes

John

Post Reply