How to enable mouse in QBasic

I'd like to make a program with mouse controls but can't get any information how to do that. For me everything is clear about keyboard scancodes, but where to get information about using mouse in Qbasic. Please help me to find a solution. Thanks.

Comments

Hello, I wrote a mouse routines library for Quick Basic. It works both for interpreted programs and compiled programs and it is very easy to use. You can download the library from this site at http://www.programmersheaven.com/search/download.asp?FileID=6765It include explanation and simple examples.Good look and remember you can make any question. Don't forguet to rate the library.

Marinsoft

: I'd like to make a program with mouse controls but can't get any information how to do that. For me everything is clear about keyboard scancodes, but where to get information about using mouse in Qbasic. : Please help me to find a solution. : Thanks.: :

I wrote the following program several years ago, and it is still the easiest way I have found to use the mouse in QBasic programs. Simply copy the Mouse sub-routine into a new program, then call it with a parameter of "1" to show the cursor, "2" to hide it, or "3" to read the mouse buttons & coordinates. To create your own programs, just replace the code in the "Main Program" section with your own code, and you're ready to go! Hope this helps, and feel free to contact me withany questions. So long!

I am new high school boy here and begineer in Q Basic too. In the code you have send, I hope that "Absolute(100)" is only called but not declared. Also there is no any sub- procedures of "Absolute(100)"

Also please help me in converting ".bas" files into ".exe".....................I am so hopeful from you........

Thanks for your interest in my code. To answer your questions; no, the statement "Call Absolute" is not declared, nor will you find a sub-procedure relating to it. This is because the statement is built-in to QBasic, much like the "SQR()" function, which returns the square root of any value in the parentheses, or "ABS()", which returns a pure numeric value, without regard to + or - signs.

The "Call Absolute(100)" statement tells QBasic to execute a special routine written directly in binary machine language, and the number in parentheses (in this case, 100) tells QBasic the memory location where that machine language code begins.

Notice the series of "Poke" statements immediately proceding the Call Absolute statement, beginning with "Poke 100,184". These statements tell QBasic to "Poke" (write) specific binary values directly into memory, at a specific address. Thus, the first Poke statement tells QBasic; "write into memory address 100, the value 184". (QBasic automatically converts the decimal value 184 into binary and then writes that value into memory.)

Now, if you'll notice, the next Poke statement specifies memory location 101, the next one 102, and so on. This is why we use Call Absolute with the value 100. However, had the first statement read "Poke 200,184", then we would have used "Call Absolute(200)".

The remaining Poke statements write various binary values into memory, and these values correspond to specific machine language commands, which instruct QBasic how to interact with the mouse driver. Different commands could just as easily relate to some other device, such as a soundcard or CD-Rom drive.

As for how QBasic knows where the machine code ends, notice the last Poke statement; "Poke 117,203". In this case, the value 203 represents the machine language "return" command, which sends QBasic back to the statement immediately following "Call Absolute(100)", where your program resumes as normal.

As far as converting ".bas" files into ".exe" (executable) programs is concerned, you need a type of program known as a "compiler". QBasic, however, is an "interpreter" program, which converts Basic code statements into machine language one-by-one, line-by-line and then executes them immediately on-the-fly. Therefore, each time you wish to run your program, QBasic needs to re-interpret your code, which is why it cannot run on its own. In effect, QBasic is actually doing the hard work; your program is simply telling QBasic what to do.

By contrast, a compiler converts basic code statements into machine language, but it does not execute them immediately. Instead, it writes those commands, in machine language form, into a separate file, which becomes your executable (.exe) program. Once this process is complete, your program can be run on its own, without the compiler's help.

As it happens, the QBasic interpreter program was actually derived from a related program called "QUICKBasic". QUICKBasic is a true compiler, and actually sold as a professional development tool. Around the time that Microsoft released MS-Dos version 5.00, they wanted to get more people interested in programming, so they effectively "stripped-down" the QUICKBasic compiler into the QBasic interpreter program, and bundled it with MS-Dos, free of charge.

Therefore, the easiest way to convert your code to .exe programs would be to compile them with QUICKBasic. Unfortunately, Microsoft no longer distributes QUICKBasic, but I have a copy of it somewhere, and If I can find the disc, I'll happily send you a copy. If not, you might try Googling it - there are still a few links to it out there. Another option would be to try FIRSTBasic. This is another Basic compiler program, created by a company known as POWERBasic. It is slightly less compatible with QBasic code than is QUICKBasic, meaning your code may need some minor alterations, however it can be downloaded directly from programmersheaven at the following link; http://www.programmersheaven.com/download/16396/download.aspx , and with some practice, you'll find it just as easy to work with as QBasic!

I hope this information was helpful, and I welcome any further questions you may have - it's always a pleasure to help out a fellow programmer! Take care for now, and above all, Have FUN programming!Sincerely,Daryl Dubbs

Hello again, Suraj! I'm afraid I still have not found my QuickBasic disc. However, I did find a .zip file online containing the most recent version of QuickBasic, namely version 4.5. I would attach a copy to this post, but this forum does not allow uploading executable files. You can, however, try downloading it yourself from the "downloads" page of www.qbcafe.net, where I found it. I hope this helps. It's a real pleasure to lend a hand when I can, because I remember what it's like to be just starting out, wishing someone could do the same for me! And of course, as always, remember to Have FUN programming! So long for now - let me know if you have any further troubles!Daryl

Hello again, Suraj! I haven't heard from you in a while, so I thought I'd drop you a line & see how you're doing; were you able to find a copy of QuickBasic? Also, I was just wondering if my mouse code has been helpful to you. Please give me a shout if you get a chance, and certainly if you've any more questions I may be able to help with - always a pleasure to share knowledge with others! Take care for now, & whatever else you do with your programming, HAVE FUN!Flurng