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.

DarkBASIC Professional Discussion / How can I do This

Author
Message
Tidus
22
Years of Service
User Offline
Joined: 17th Oct 2003
Location:
Posted: 18th Nov 2003 13:14
My problem is: I have a game and the menu Loop is inside a gosub and when I click in a button I want to finish this gosub and come back to the place where the program enter in the gosub but when I try to do this the program ends.
I have tryed to put if (Mouseclick()=1) then return
(Mouseclick()=1) then exit
I they every do the same ends the program.
Just for know I use DarkBasic Pro 5.1b that is the last version.
Beta 1
22
Years of Service
User Offline
Joined: 27th Aug 2003
Location:
Posted: 18th Nov 2003 14:44 Edited at: 18th Nov 2003 14:46
If you could post some more code that would help.

First thought - is it ending or is it crashing?

Normally a gosub looks like this



Say you want to display a menu but then leave the subroutine when the user clicks on a button then if that event (the using clicking start) results in a variable "start" being set to 1 then you want something like this



This way the routine will wait in the subroutine then when start=1 leave the repeat/until loop and return to where ever it was when you did GOSUB menu

IF you have a line like

if Mouseclick()=1 then return (you dont need the outer brackets)

in place of my RETURN line then unless the user is pressing the mouse button at the moment that line executes the program just carries on without returning and will probably start running the next subroutine/function or just stop if its the last line of code.

So I think your problem is probably that your not waiting for a mouseclick just checking once.

If thats right and you just want to wait until the mousclick event then you could just do this:




Theres probably another 100 ways of doing that though.
Shadow Robert
23
Years of Service
User Offline
Joined: 22nd Sep 2002
Location: Hertfordshire, England
Posted: 19th Nov 2003 00:02



To Survive You Must Evolve... This Time Van Will Not Escape His Fate!
900mhz | 256mb | FX5200Ti 52.16 | Dx9 | WXP-Pro

Login to post a reply

Server time is: 2026-07-26 20:16:29
Your offset time is: 2026-07-26 20:16:29