|
Answer» Mmm, 1988 programming
Is there a way to make it so that the CTRL+C command will not allow a QBASIC program to close? I know it sounds menacing, but its not.
The program I was writing (for some reason, it wont load, so now I have to REWRITE it ) asks a user for the password to access a system.
If a user didn't have a password (right now, for my current version) they can press CTRL+C to bypass it.
(^^ Yes, this is one of my lame programs that I created for no reason, except for the fact that I am bored^^)
(And my solution for not using loops: Goto commands mixed with IF-THEN statements) You can tailor the content of NoBreak.zip from the Miscellaneous section on this site, but don't forget to include some method of terminating the program.
Good luckDocumentation:
So you forgot your password, and you need a way out of it: Press the following keys, in order: CTRL+C+D+TAB+SHIFT (These keys can be pressed by this order: Pinky on TAB, That one finger on D, Ring on C, and thumb on SHIFT and CTRL) As you are holding this down, start typing the following text: "India Is Great India Is Great India Is Great India Is Great India Is Great India Is Great India Is Great India Is Great India Is Great India Is Great India Is Great India Is Great India Is Great India Is Great India Is Great India Is Great India Is Great India Is Great India Is Great India Is Great India Is Great India Is Great India Is Great India Is Great India Is Great India Is Great India Is Great India Is Great India Is Great India Is Great India Is Great India Is Great India Is Great India Is Great " and press ENTER
The CONF$ data will be reset, and the next time you restart your computer, it will allow you to enter a new password.
Another question for you experts: How could I make a key combination activate a sub or GOTO command, for EXAMPLE: If I wanted CTRL+H to give the command Code: [Select]goto help or Code: [Select]call helphow would I go about doing that? Quote from: Zylstra on July 16, 2007, 08:30:44 PM Documentation:
Another question for you experts: How could I make a key combination activate a sub or GOTO command, for example: If I wanted CTRL+H to give the command Code: [Select]goto help or Code: [Select]call helphow would I go about doing that?
Am not sure what the Documentation part of your response is all about but I might just get round to trying it one fine day.
You didn't say what version of QBasic you are using but key combinations generally only allow for Gosub EXECUTION. You could call a sub from within the Gosub routine. Here is an example of CTRL+H but note this executes only when Capslock, Numlock and Shift are Off..
Code: [Select]CLS KEY 18, CHR$(&H4) + CHR$(&H23) ' user defined key within range 15 - 25 KEY(18) ON: ON KEY(18) GOSUB 40
do ' simplest of loops to KEEP prog running loop ' until the Ctrl+h combination is pressed
40 SHELL "type c:\windows\system32\eula.txt" ' test END RETURN
CHR$(&H4) is the Keyboard Flag for CTRL and CHR$(&H23) is the Scancode for the letter H.
The example has been tested using QB ver 4.5, no warranties given.
Good luck
Okay, thanks, Dusty
I have the newest version of Qbasic (1988... really new...) So all should work well
|