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 / Hangman Problem

Author
Message
Call me coder
20
Years of Service
User Offline
Joined: 5th Mar 2005
Location:
Posted: 1st Sep 2005 02:22
hey im trying to make a hangman where you can change the words. I am trying to think how but it doesnt work. I have looked in all the help files and still cant find nething. Here is the code im trying to get working.





TO ALL THOSE PROGRAMING PEOPLE OUT THERE!
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 1st Sep 2005 04:04
Lol.

Don't take this the wrong way, but that's gibberish! If you're new to programming, that's understandable, so don't worry - we can sort it out.

First of all, in hangman, you need to supply the list of words rather than the user type them in. On that assumption, you would put all the words in data statements as in:

Data "Horse",House,"Computer","Fish","Rocket"

and so on. You can't use data statements in the way you have used them.

Now if you did want to enter 10 words in, then you would use a loop instead of 10 input lines. However, you couldn't use the same string variable each time because you would simply delete the previous word.

So, you use string arrays:

Dim Words$(10)

This dimensions a string array variable called Words and lets you create 10 of them Words$(1) to Words$(10). In actual fact, there's also Words$(0) making 11 in total, but you can ignore that for now.

You would have the user enter the words in as follows:

For A=1 To 10
Input "Type another word " ,Words$(A)
Next A

That's all there is to it!

To simulate the whole of your program above, you would use:

Input "How Many Words: ",W
Dim Words$(W)
For A=1 To W
Input "Type another word " ,Words$(A)
Next A

Bit of a difference in size yes?

TDK_Man

Call me coder
20
Years of Service
User Offline
Joined: 5th Mar 2005
Location:
Posted: 2nd Sep 2005 03:28
my teachers would like me to make a hangman program so they can use the word of the day ect. I dpnt want to have to make a new one every day.


TO ALL THOSE PROGRAMING PEOPLE OUT THERE!
Robot
20
Years of Service
User Offline
Joined: 27th May 2004
Location:
Posted: 2nd Sep 2005 09:07
Have it read the words/word from a .txt file.

The happenings of tommorow are behind us now
Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 2nd Sep 2005 09:27
I was bored so I made this for you. This loads a text file (as Robot suggested). The text file (example attached) should consist of a date and a word for that day "09/01/05 Playstation". Only use one line per word. I made a lot of rem statements but if you have questions just ask. Just don't tell your teacher you did it yourself... direct him/her to here... convince him/her to order lots of Darkbasic Pro CD's for your school.

Attachments

Login to view attachments

Login to post a reply

Server time is: 2025-05-22 08:53:25
Your offset time is: 2025-05-22 08:53:25