Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

How to enable mouse in QBasic

2»

Comments

  • sagar123sagar123 nepalMember Posts: 2

    And can you also suggest me some sites were I can view simple mouse program..

  • flurngflurng Member Posts: 10
    edited February 2015

    Greetings, Sagar123!

    I hope this is not too little, too late, however I just now saw your post and I felt I should lend whatever help I can. Perhaps you didn't see it, but another member had asked for an explanation of how the mouse sub-routine works, so I responded with the following post:

    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 preceding 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.

    I hope this helps, however should you have any more specific questions, as to what in particular you don't understand, please feel free to respond here, or email me at: flurng@gmail.com, and I will be happy to provide any help that I can.
    In the meantime, I recommend you download and run the sample program, tinker with it a bit, and try to get a feel for how the process works. So long for now & good luck in your programming adventure!

2»
Sign In or Register to comment.