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 / I can't figure this out.

Author
Message
Technobabble91
14
Years of Service
User Offline
Joined: 3rd Jul 2009
Location:
Posted: 3rd Jul 2009 15:56
I have been writting my first program, and all was going well, but I wanted it to wait until you press enter to leave the program, and I have yet to have accomplished that.

here is the code for you to see.


I don't why I exist, so I have no reason not take your money and run.
TheComet
16
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 3rd Jul 2009 16:54
What I would do is a repeat loop:



This loop will wait until the return key is released, and then you can wait until it is pressed.



Or you can replace
with


But I recommend the first way, because the user can type silly things into the program before pressing enter with the second method.

Hope that helped!

TheComet


Make the path of your enemies easier with Waypoint Pro!
Dark Dragon
16
Years of Service
User Offline
Joined: 22nd Jun 2007
Location: In the ring, Kickin\' *donkeybutt*.
Posted: 3rd Jul 2009 17:12
DAng, Comet, you beat me to it.

Your signature has been erased by a mod because it was too big.CHANGE IT OR DIE!!!!!
Technobabble91
14
Years of Service
User Offline
Joined: 3rd Jul 2009
Location:
Posted: 3rd Jul 2009 17:12
Well that almost worked.

I tried both methods, and my results varried greatly.

The first just repeated the entire programe sequence until I stopped it, and the second one worked, but I had the problem of you could type in everything you wanted before hitting enter

I don't why I exist, so I have no reason not take your money and run.
Grog Grueslayer
Valued Member
18
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 3rd Jul 2009 19:02 Edited at: 3rd Jul 2009 19:18
The better way to do it is to avoid the Enter key as a method to quit the program since Enter is used to stop getting INPUT. Also having it check for a key to quit the program without a loop around it gives you about 2 milliseconds to decide if you want to quit or not before it loops again. You can force the user to decide and give them all the time in the world to choose by making a DO/LOOP within the first DO/LOOP to just look for two keys... one to continue the program and one to end it. Also there was no need for SYNC since you didn't turn it on (it'll automatically SYNC with any change).



Edit: I forgot to mention that asking for the user name should be on the outside of the DO/LOOP. If Bob is using the program then Bob should still be Bob if they decide to continue.

Technobabble91
14
Years of Service
User Offline
Joined: 3rd Jul 2009
Location:
Posted: 3rd Jul 2009 19:41
Thanks. that works, but now I am going to have to study all these new commands.

Every ime I have tried to learn a programming language I have relied entirely on tutorials to help. This time I'm not doing that, but instead looking at the documentation and examples. It will take a long time, but I have a trick up my sleeve. (Looks around) 12 computers. I figure if I can make a simple game using basic programming I will buy the program, but if I can't learn to make it with a whole year to do it I will just quit and walk way in despair.

I don't why I exist, so I have no reason not take your money and run.
TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 3rd Jul 2009 21:14 Edited at: 3rd Jul 2009 21:15
Did you know there is already a key in DB defined as a quit key?

Unless you turn it off, the Esc key always quits a DB program.

As Grog says, your loop in conjunction with the inputs give you little time to do anything.

PS: Get into the habit of indenting your code - it makes it so much easier to follow. The snippet you posted is just about at the limit of how big it is before it gets hard to follow.

Barrie

Technobabble91
14
Years of Service
User Offline
Joined: 3rd Jul 2009
Location:
Posted: 3rd Jul 2009 21:27
yes I did. I am doing this so that I can learn every detail of this language.

I love it so far.

Also indention
Is when you have your code
Done like this, so that it is more readable. Right?

I don't why I exist, so I have no reason not take your money and run.
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 3rd Jul 2009 22:55
theComet,
Your code was a little off.

repeat
until returnkey()=0

It should say returnkey() = 1

[url="http://dbcc.zimnox.com"][/url]
TheComet
16
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 3rd Jul 2009 23:54
@ Phaelax

I'm sure it should be as it is. Because I'm doing this:



TheComet


Make the path of your enemies easier with Waypoint Pro!
TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 5th Jul 2009 04:44
I see why you are using the:

Quote: "repeat
until returnkey()=0"


You are trapping the program counter until the Return key is released after the age has been inputted - to stop pressing Enter after entering your age from also quitting the problem.

Enter isn't the best key to use for quitting the program as you already know...

Technobabble91:

Your code indented:



Not so important now, but add a few nested loops and you'll be glad you started indenting your code at an early stage...

Barrie (TDK)

Technobabble91
14
Years of Service
User Offline
Joined: 3rd Jul 2009
Location:
Posted: 5th Jul 2009 07:56
Yeah thanks. As you can tell I am pretty new at this. I don't have the money either, so I am Using my vast number of computers. (Don't ask) To keep using the demo. I have to say that this is a lot of fun though.

The indentation is actually very helpful thankyou.

One last thing. I have been using Darkbasic, and I can't find any spell-checker type thing (syntax checker?) Do you know if one exists? and why is the word processor thingy so dark?

I don't why I exist, so I have no reason not take your money and run.
TheComet
16
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 5th Jul 2009 12:27
Quote: "One last thing. I have been using Darkbasic, and I can't find any spell-checker type thing (syntax checker?) Do you know if one exists? and why is the word processor thingy so dark?"


Press f4 for syntax checking, press f5 for executing. I suppose you are using the built in editor. You should download DarkEdit. It is much easier to use.

TheComet


Make the path of your enemies easier with Waypoint Pro!

Login to post a reply

Server time is: 2024-05-20 10:55:52
Your offset time is: 2024-05-20 10:55:52