Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / How do I use mouse command?

Author
Message
Sequence
13
Years of Service
User Offline
Joined: 16th Mar 2011
Location: Canada
Posted: 16th Mar 2011 12:42
[quote}
Print "Hello World!" : Wait Key
For X=50 to 2 step -1 : Print X : Next X
print "1";
Repeat
AskM=MouseClick()
AskK$=Inkey$()
Until AskK$>"" or AskM>0
Wait Key
[/quote]
I press the mouse button, and it never jumps out of the repeat statement.

And what's with the () after mouse and inkey? Am I supposed to put numbers, letters or variables in there or something?
Like.

AskM= MouseClick(-9532)

If all the "1"s are in the right place, it'll work like a charm.
Somarl
13
Years of Service
User Offline
Joined: 11th Feb 2011
Location: UK
Posted: 16th Mar 2011 14:55 Edited at: 16th Mar 2011 14:58
It might be that it is working but doesnt look like it because of where you have that wait key statement.

Its checking for wait key first then when you hit a key jumping straight into the repeat loop, then after a mouseclick another wait key.

Try this



It might help you understand what is going on.

The () after them is just because it is getting a value from a function in DB, which should either be a number depending on what you have done.

So:
if mouseclick() = 1
Is trying to check if the mouseclick 1 is clicked because all the numbers in the mouseclick function relate to what has been pressed.
I think mouseclick() = 2 is right mouse, some are a combination of buttons pressed etc
Sequence
13
Years of Service
User Offline
Joined: 16th Mar 2011
Location: Canada
Posted: 17th Mar 2011 01:22
You've removed part of my program.

After exhaustive measures it appears that the compiler is at fault.

After the "Hello World" there was a "wait key"

That WAIT KEY takes the input from it and puts it into the Inkey$ statement and it jumps out of my repeat loop and there's no way to stop it.... well, I did only try 3 ways.

I've only been using Dark Basic for 1 hour and found problems with it.... Like when it prints those 50 numbers, at the top of the screen are remnants of the letters printed from the line above. There's another peculiar compiler problem too!

If all the "1"s are in the right place, it'll work like a charm.
Somarl
13
Years of Service
User Offline
Joined: 11th Feb 2011
Location: UK
Posted: 17th Mar 2011 11:53
Yeah i did, i was just trying to demonstrate what wait key was doing.
Wait key just literally pauses the entire program until you kit any key before moving on and using the rest of the code.

If you show me more specifically what you want it to do and post up your code ill see if i can demonstrate how to make it work the way you want, hopefully help you get to the bottom of this problem.
Sequence
13
Years of Service
User Offline
Joined: 16th Mar 2011
Location: Canada
Posted: 17th Mar 2011 12:50

That is the whole program.

What I am trying to do is, after the first wait key is triggered, I am keeping the loop going until another character OR a mouse button is pressed.

However, what happens instead is the previous WAIT KEY "data" is accepted as the INKEY$, thus AskK$ is greater than "" and it falls through. Could this be because my computer is so fast that it has taken maybe 20 identical keystrokes in the place of the key being pressed only once?


Also, Set Text Size isn't increasing the size of my characters displayed.

The in program "help" is very shallow.

Isn't there a BOX command that doesn't fill but merely makes an OUTLINE of a box? I've resorted to manually making hollow boxes.

If all the "1"s are in the right place, it'll work like a charm.
Hodgey
15
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 17th Mar 2011 13:21
Quote: "After exhaustive measures it appears that the compiler is at fault."


I have to disagree. Each command and variable in your program is working as it should. The reason your program appears to not work is because the 'wait key' only works for 1 iteration and it doesn't check for you to let go of the key you are pressing.

So you press a key, the wait key disappears in an instant, computers work very quickly, while that key is still being pressed, your loop is entered. A thousand iterations (loops) could occur in the time that the wait key disappears and you letting go of the key.

Small example

How many times do you think the inkey$ command will have detected the key that you have pressed?

If you take out both of the wait key commands in your program you will find that the mouseclick command works the way you want it to.

If you want to keep the wait key command before your loop then I suggest utilizing a boolean. Here is an example:



I hope this clears things up a bit.

A clever person solves a problem, a wise person avoids it - Albert Einstein
Sequence
13
Years of Service
User Offline
Joined: 16th Mar 2011
Location: Canada
Posted: 17th Mar 2011 14:04
Does Dark Basic support Modulo math? It isn't in the manual as far as I can tell.

If all the "1"s are in the right place, it'll work like a charm.
Sequence
13
Years of Service
User Offline
Joined: 16th Mar 2011
Location: Canada
Posted: 17th Mar 2011 14:11


Okay, although I didn't see it in the manual, the problem was when I typed mod into the editor, it did not turn blue, and I thought it wasn't a recognized command word.

If all the "1"s are in the right place, it'll work like a charm.
Sequence
13
Years of Service
User Offline
Joined: 16th Mar 2011
Location: Canada
Posted: 17th Mar 2011 14:46


Hey, get a load of this!

Some of the keys on the keyboard seemed as though they couldn't be held down for as short periods of time as others.

So I kept pressing the same key over and over.... That triggered the windows "sticky key" program to ask if I wanted to activate it or not. Well, guess what happened after that.

The FONT that I was using reverted back to the FONT that the program STARTS WITH, and the same size, too.

If all the "1"s are in the right place, it'll work like a charm.
Sequence
13
Years of Service
User Offline
Joined: 16th Mar 2011
Location: Canada
Posted: 17th Mar 2011 15:14


Got a new problem.

The program gets stuck, where I wrote the word stuck.

All it does is a "ding" sound with any key press after I press lower case "q". But it DOES quit when I press the SPACE BAR for some reason.

If all the "1"s are in the right place, it'll work like a charm.
Sequence
13
Years of Service
User Offline
Joined: 16th Mar 2011
Location: Canada
Posted: 17th Mar 2011 15:35
Okay, I figured it out.

In AMOS Professional, if you have functions, they are ignored if they are run into as the program moves down the lines. In DarkBasic, when a FUNCTION is encountered, the program gets stuck. Too bad the manual doesn't tell you this.

If all the "1"s are in the right place, it'll work like a charm.
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 17th Mar 2011 17:53
The manual was written for V1.0. You are most likely using 7.6 or thereabouts, there are 10 years of updates since the manual was written.

You must use

END

at the end of your mainline code, before the functions are declared. It is standard programming practise to exit gracefully, rather than expect the program to just "run out"

Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 17th Mar 2011 18:57
Quote: "Isn't there a BOX command that doesn't fill but merely makes an OUTLINE of a box? I've resorted to manually making hollow boxes."


If you get IanMs Matrix 1 Utilities Plugin you can use the BOX OUTLINE command. It seems silly to download it for one single command but it's full of useful commands you'll eventually want/need.

http://forum.thegamecreators.com/?m=forum_view&t=85209&b=18

Login to post a reply

Server time is: 2024-11-24 06:57:43
Your offset time is: 2024-11-24 06:57:43