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 / Function Help Plz

Author
Message
Dexter_
17
Years of Service
User Offline
Joined: 13th Jan 2007
Location:
Posted: 13th Jan 2007 22:40
This is on DBPRO



I don't know how to get the function to work...it's a calculator.
When I put the function at the beginning, it closed the program.

Umm what am I doing wrong?

Thx for help

Im a noob
Dexter_
17
Years of Service
User Offline
Joined: 13th Jan 2007
Location:
Posted: 14th Jan 2007 02:28
plz help

Im a noob
Kieran
18
Years of Service
User Offline
Joined: 6th Aug 2006
Location: Hamilton, New Zealand
Posted: 14th Jan 2007 06:00 Edited at: 14th Jan 2007 06:02
well first of all i think it should be if mousclick()=1 not if mouseclick()=click

EDIT: another thing is i think you can only have to ands per if so say you had

if me = 1 and you = 2 and we = 3 and he = 4
`code here
endif

would be

if me = 1 and you = 2
if we = 3 and he = 4
`code here
endif
endif

Kieran
18
Years of Service
User Offline
Joined: 6th Aug 2006
Location: Hamilton, New Zealand
Posted: 14th Jan 2007 06:04
and about you sig, no1 is a noob unless they act like one, i only believe there are newbies, you are a noob if you don't try to get better and if you act like one.

Dexter_
17
Years of Service
User Offline
Joined: 13th Jan 2007
Location:
Posted: 14th Jan 2007 09:30
ty!
i fixed it i didnt know that stuff :p

ill change my sig in a bit too

Im a noob
Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 14th Jan 2007 10:02 Edited at: 14th Jan 2007 10:13
The function is working exactly the way you made it. If the mouse isn't clicked it exits the function. If it is clicked in that area it does nothing... "exit" should only be used to exit a loop not a function. If you want to exit a function before the functions end use "exitfunction". There's nothing in the function that tells the rest of your code if the button has been hit.

The function just needs to have a switch that starts at zero (which is off) and only turns on when the mouse has been clicked and is in the area being checked. At the end of the function you add the same switch so the function returns the variable. If the switch is still off the button hasn't been clicked... if it's on then it has been clicked.

I also changed the function to the proper way to handle x and y coordinates. The x and y of the upper left corner and the x and y of the lower right corner... which is just like the "box" command.



What would make it easier is if you used absolute coordinates. You can force the screen size by using the command "set display mode" so you don't have to use "screen width()" and "screen height()" to create the buttons... but use exact coordinates (like I did when calling the function). Also you should probably put all those button coordinates in an array so you can easily create and check every button with a couple of for/next loops rather than an "if" statement for each button.
Gil Galvanti
19
Years of Service
User Offline
Joined: 22nd Dec 2004
Location: Texas, United States
Posted: 14th Jan 2007 17:03
Quote: "another thing is i think you can only have to ands per if so say you had"

Where did you get that idea, I use more than two all the time and it works fine

Pirates of Port Royale
Live the life of a pirate.
Dexter_
17
Years of Service
User Offline
Joined: 13th Jan 2007
Location:
Posted: 14th Jan 2007 22:30
ok, two things:
-who can clarify on the 'and' thing
-why cant my function have mouseclick()=click instead of mousclick()=1

Im a noob
hyrichter
20
Years of Service
User Offline
Joined: 15th Feb 2004
Location: Arizona
Posted: 15th Jan 2007 00:20
Quote: "-who can clarify on the 'and' thing"

You can have as many "ands" as you want in an if statement. The compiler won't care.

Quote: "-why cant my function have mouseclick()=click instead of mousclick()=1"

Using mouseclick()=click like you have it in that function is fine.

Good performance is better than a good excuse.
CodeSurge -- DBP Editor for serious programmers.
Kieran
18
Years of Service
User Offline
Joined: 6th Aug 2006
Location: Hamilton, New Zealand
Posted: 15th Jan 2007 00:33 Edited at: 15th Jan 2007 00:34
@gil
it was in a tutorial it had something like this

if mousex()>25 and mousex()<10
if mousey()>25 and mousey()<10
`stuff here
endif
endif

so i assumed you can only use one and

SORRY FOR CONFUSION! thats what you learn from a bad tutorial i guess

EDIT: when i tried mouseclick()=click it didn't work thats why i thought it had to be 1

Dexter_
17
Years of Service
User Offline
Joined: 13th Jan 2007
Location:
Posted: 15th Jan 2007 00:39
well if 'click' is one of the variables in the function, and if mouseclick()=click....then pretty much

saying:
if click=1 is the same as saying
if mouseclick()=1

right?
hyrichter
20
Years of Service
User Offline
Joined: 15th Feb 2004
Location: Arizona
Posted: 15th Jan 2007 03:15
Correct.

Good performance is better than a good excuse.
CodeSurge -- DBP Editor for serious programmers.

Login to post a reply

Server time is: 2024-09-25 15:28:03
Your offset time is: 2024-09-25 15:28:03