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 / inc var prob (dbpro)

Author
Message
Krimzon DestinE
19
Years of Service
User Offline
Joined: 18th Sep 2005
Location:
Posted: 28th Dec 2005 01:53
For some reason, the strikes variable increases no matter if the guess is correct or not, and it is increased by some funky amounts. Anyone have any idea why?

Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 28th Dec 2005 03:54
You just need what amounts to a variable switch. It needs to be defined outside of the for/next loop (as off) and is turned on when a letter is found. After the loop check if the switch is still off (no letter found).

The way it is right now everytime a letter does not equal "guess$" is when it increases strikes.


Krimzon DestinE
19
Years of Service
User Offline
Joined: 18th Sep 2005
Location:
Posted: 28th Dec 2005 05:41 Edited at: 28th Dec 2005 05:43
this increases the strikes variable by one, only problem is it does it each time the user inputs a letter despite being wrong or right.

Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 28th Dec 2005 06:43
That looks good. It just needs to be opposite. You want the switch on when it gets a letter and you want the if/then to check for the switch being off.


Krimzon DestinE
19
Years of Service
User Offline
Joined: 18th Sep 2005
Location:
Posted: 29th Dec 2005 00:17
like this?:



because it's doin the same thing
Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 29th Dec 2005 09:11
It's still looking for a wrong answer. It switch needs to start out off and turn the switch on when finds a correct letter in the string then check if the switch is still off (no right answer found).

Here are the steps it goes through (the way your code is):

Lets say the word is "maine" and the letter typed in is "a".

1. "notwrong=1" before the for/next loop.
2. "m" is the first letter and is not the guess letter so it does "notwrong=0"
3. "a" is the next letter and is the guess letter.

I'll skip the other letters (each letter is not in the string so each one makes "notwrong=0").

4. Outside of the loop because "notwrong" is zero it adds to "strikes".

Even though "a" was a correct letter in the string its still marked as wrong because of the other letters.


Krimzon DestinE
19
Years of Service
User Offline
Joined: 18th Sep 2005
Location:
Posted: 30th Dec 2005 04:30
thanks man, let's see how far I can get now on my own.
Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 30th Dec 2005 04:35
Np


Login to post a reply

Server time is: 2024-09-24 11:23:30
Your offset time is: 2024-09-24 11:23:30