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

Author
Message
MacMan
12
Years of Service
User Offline
Joined: 9th Apr 2012
Location:
Posted: 13th Apr 2012 21:43
I think I have all my code done but my program won't run because I keep getting errors like this, The name 'title' duplicated in the program at line 391.Compilation Failed (Syntax Errors). Any suggestions? Also I'm trying to add a way for my program to accept upper or lower case letters and figure out how to get the system to detect if a letter has previously been guessed or not. Any help is appreciated greatly.

nonZero
12
Years of Service
User Offline
Joined: 10th Jul 2011
Location: Dark Empire HQ, Otherworld, Silent Hill
Posted: 14th Apr 2012 00:09
On my phone so I can't read your code snippet properly. Will give you a breakdown to a system (many exist this is but one):
Essentially we need but 1 array: Guessed() with a depth of 26 (we could use 25 but I like to ignore index 0 for convenience). Basically DIM guessed(26). Now each item will be 1 or 0 indicating if it was guessed. This can be checked against the word we are tryna guess too!
As for case, convert all input to a single standard using the UPPER$() or LOWER$() functions when running comparisons. For input, you can use KEYSTATE(), the windows entry buffer, INKEY$() or the traditional INPUT command.
Finally, about your compile errors, do me a favour and post a screen cap or two of some of them so we can see the exact message. Lack of write permission is the most common cause but there are other more exotic possibilities too.

Hodgey
14
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 14th Apr 2012 00:39 Edited at: 14th Apr 2012 00:40
When I ran the snippet, the errors I got were "Lable ? doesn't exist" referring to your GOTO startofprogram line. You forgot to add the startofprogram: label at the top of your program. You can learn more on the goto command in the help files. Generally, the use of the GOTO command is frowned upon, here is a good thread to read through in your spare time.

The other problems I came across were that you had an end statement in your Title() function which basically caused the program to exit immediately. You also dimmed an array and then undimmed it a few lines later which is kind of pointless so I commented out the offending line. Here's the result:



Edit: Properly indented code is greatly appreciated by other programmers and makes code a lot easier to read so you should start putting indentation into practice.

MacMan
12
Years of Service
User Offline
Joined: 9th Apr 2012
Location:
Posted: 14th Apr 2012 02:01
What should I be using in place of the GOTO command?
Hodgey
14
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 14th Apr 2012 06:45
You seem to be grasping functions well so that's a good place to start. You can also use subroutines (GOSUB) and most DBP programs have a main loop, typically a do-loop.

nonZero
12
Years of Service
User Offline
Joined: 10th Jul 2011
Location: Dark Empire HQ, Otherworld, Silent Hill
Posted: 14th Apr 2012 13:19 Edited at: 14th Apr 2012 23:22
Okay, this is reeeeaaaaally embarrassing, but I thought it would amuse ya'll

I got up this morning and remembered I'd posted some info in this thread so I whipped up an example code... And then got carried away - as usual since I cannot live life but by extremes and " 'overboard' string cannot be found in 'nonZero.dic' ".
So here's the extremist program. It hasn't a wordlist but that's fine, just change the "todaysword$" variable. It's easy enough to build a wordlist in.



Quote: "Vegeta, what's the scouter say about his overboard level?"


Quote: "IT'S OVER 9000!!!"


Heh, yeah.

PS: If anything doesn't make sense ask!
PPS: If anyone sees some problems with my code, pleeeez correct me, I wanna level up some more still.

[EDIT] Wow, I was half asleep this morning. Was looking over everything I did today and stumbled upon this example I brewed up. Heh, my "EEEEEE" line was still in the code (I just mark places I'm gonna put messages and add the messages post-code with quickies). Ya know this really is over-board, lol. All I meant to do was illustrate what I meant in my post last night. Should've actually checked the thread properly this morning before making that program as I see Hodgey already posted some code. But after all hat effort, I had to share this wierd take on hangman. Anyway edited out the bad line. Might even edit this post in the future, depends. Just thinking it's pretty ironic I made it with 3D considering the original game was played with a pen and paper. Just remembering that makes me feel old...[/EDIT]

Login to post a reply

Server time is: 2024-05-18 01:57:39
Your offset time is: 2024-05-18 01:57:39