Guess who's back

If you have questions about any aspect of QBasic programming, or would like to help fellow programmers solve their problems, check out this board!

Moderators: Pete, Mods

Post Reply
izidor
Veteran
Posts: 110
Joined: Wed Apr 22, 2009 3:13 am
Contact:

Guess who's back

Post by izidor »

I'm back with my questions :D

Here is my (QB64) problem, obviously i want to create a box by clicking LMB. Can anyone help? And to Pete in the future is there going to be "QB64 Questions & Answers" forum or sub-forum or how the heck is that called?

Code: Select all

SCREEN 9
_MOUSESHOW
DO
DO
LOOP WHILE _MOUSEINPUT
click = 0
IF _MOUSEBUTTON(1) and click = 0 then
click = click + 1
x = _MOUSEY
y = __MOUSEX

ELSEIF _MOUSEBUTTON(1) and click = 1 then
LINE (x,y)-(__MOUSEX,_MOUSEY),1,B
click = 0
END IF
LOOP


User avatar
burger2227
Veteran
Posts: 2466
Joined: Mon Aug 21, 2006 12:40 am
Location: Pittsburgh, PA

Post by burger2227 »

You are not using _MOUSEINPUT correctly! It is used to find out if new data is available so all of your _MOUSEBUTTON reads need to be inside of that loop.

Code: Select all


DO 'main program loop

DO WHILE _MOUSEINPUT ' only loops when mouse has new info

' any mouse function reads go here

LOOP

LOOP UNTIL INKEY$ = CHR$(27)

_MOUSEINPUT makes sure that the program does not miss any new mouse information.

If Pete plans on making a Forum for QB64, he will have to do something about that M O U S E X function. Wonder why it keeps the _MOUSEX part?
Please acknowledge and thank members who answer your questions!
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0
izidor
Veteran
Posts: 110
Joined: Wed Apr 22, 2009 3:13 am
Contact:

Post by izidor »

Ok but that doesn't solve the problem.
User avatar
burger2227
Veteran
Posts: 2466
Joined: Mon Aug 21, 2006 12:40 am
Location: Pittsburgh, PA

Post by burger2227 »

Your CLICK variable will always be 0 because it is constantly reset to 0 every loop, but your second alternative already does that after the second click and click = 1. Take that line before the IF statement out. Even if you leave the loop because of mouse inactivity.

BTW I will not answer any more of your questions if you continue to wait days to reply or just get what you want and do not reply! This has happened WAY TOO OFTEN!
Please acknowledge and thank members who answer your questions!
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0
Post Reply