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 Discussion / Updated The Simple Text Menu

Author
Message
I am an idiot
18
Years of Service
User Offline
Joined: 25th Jul 2006
Location: Some Place Cozy
Posted: 25th Jul 2006 20:31
Yes, we've all seen the anonymous user's simple text menu. It looks something like this?

That's the Gyst of the code, I edited some things like the music and the lava1.bmp and such. But I do believe I've found a better system. I've altered a bit, such as the Do Loop, which loops continuously and endlessly, so when you've already clicked the menu "Play" button, it will do the play function, as requested, but the spaces where the text was will still act as buttons. This is not allowable in a game. Now I'm just coming back to Dark Basic, and I'm finding that if you replace Do Loop with Repeat Until... Well... Here. Let me show you what I mean.

Heh. If you can't tell the difference between the two, here it is. In the original, if you click "Play", yes the text will disappear. But if you happen to click the spot where the Exit button was, or any other menu function, then you're in for a novice mistake. (If you don't know what I'm talking about... Try it. There's no teacher better than Experience.) ... Now in the second one, if you click "Play", the play function will work, but there is no little bugs such as it exiting when you click on the spot where the exit button was. LOL. It's a quite simple fix, and if anybody has a better update for it, please post. I'm always willing to learn.


- JAKE,
OUT!

======
Ok... So what?
Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 5th Aug 2006 02:34
Hello e Jake,

Off the bat, eyeballing the code left me with a couple of questions. I tried it out, and I didn't get the error I was expecting. I was totaly expecting a 'return without gosub' error.

This seems odd to me that breaking out of the loop wouldn't cause game: and rip: to be executed again and a "return without gosub" error generated. I guess DarkBasic ignores this - but technically in Basic in general, this would be an incorrect layout of the program and maybe a habit to avoid falling into.

I wrote a quick program WITHOUT any code except for the RETURN statement as the first line. I was sure the program would fail with an error but DBC v1.13 ran it without spitting back anything! Very surprising... and not necessarily a good thing. In Basic, this is an error.

Now I'll try to help...
First, I'd get rid of the return in rip: . It isn't necessary because it contains an end statement. This is where you want things to stop, so returning isn't necessary.

Next, in the second line of the loop, I would use goto rip instead of gosub.

Instead of the Repeat Until g=1, I'd keep the original Do Loop and add as the last line inside the loop:
if g=1 then goto rip


This seems a little more code correct, but I'm no genius.
Here's the code:



Enjoy your day.

Login to post a reply

Server time is: 2025-05-25 08:13:27
Your offset time is: 2025-05-25 08:13:27