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 / Need help again (noob) I making a game which uses different genders...

Author
Message
Deathead
18
Years of Service
User Offline
Joined: 14th Oct 2006
Location:
Posted: 26th Aug 2007 03:23
I'm making a racing game which you can use different genders and I need to know what is wrong with this script...
load image "application.png",1
paste image 1,50,50
input "name";nam$
input "gender";gen$
ink rgb(0,0,0),0 : set text size 30 : set text font "neuropol"
text 260,115,nam$
text 270,210,gen$
ink rgb (255,255,255),1
if (lower$(gen$) <> "male") and (lower$(gen$) <> "female")
print "Gender '"+upper$(gen$)+"' is invalid!"
endif
do
loop

It says that male and female is invalid any help pls. I'll greatfully credit you in the game.

Code Dragon
18
Years of Service
User Offline
Joined: 21st Aug 2006
Location: Everywhere
Posted: 26th Aug 2007 03:57
The and operator can get unintuitive with complex expressions like that, try this:



I don't have DBPro on this computer so I don't know if it works.

Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 26th Aug 2007 04:06 Edited at: 26th Aug 2007 04:07
weird... it looks like lower$ is broken. if you change to upper$ and match it against "MALE" & "FEMALE" it works fine no matter what case you use in the input prompts. if you use lower$ and enter "male" it works. enter "Male" and it's invalid.

i think you found a bug, Deathead.

Code Dragon
18
Years of Service
User Offline
Joined: 21st Aug 2006
Location: Everywhere
Posted: 26th Aug 2007 04:10
Hmm, what is the reasoning behind these strange bugs appearing?

Lucy
17
Years of Service
User Offline
Joined: 19th Apr 2007
Location: Roanoke, VA USA
Posted: 26th Aug 2007 09:52
Quote: "Hmm, what is the reasoning behind these strange bugs appearing? "


Certainly a new kind of bug that's for sure. I wanted to say it's a schroedinbug, but it's not quite appropriate. Schroedin bugs are where a program that works fine for a very long time. That is until someone looks at the source code and notices a bug that should prevent the program from working. At that point, noone can get the program to work, even previously working copies.

This is more an inconsequential bug that's hardly noticed because most people are too lazy to case cast the user's input.

Nothing I say is intended to be rude. My autism means that I do not know what is rude and what isn't rude. I apologize if I seem rude. It is not my intention.
Dazzag
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Cyprus
Posted: 26th Aug 2007 10:53 Edited at: 26th Aug 2007 10:56
Tried out his code and it worked just fine on mine. Were you adding in spaces by any chance? Anyway, try this version which will trim spaces from the beginning and end:-



Note also that you don't need to put brackets around the segments of the AND function. eg. you don't need to say "IF (A<>1) AND (B<>1)", you can say "IF A<>1 AND B<>1". Only use brackets for examples like "IF (A<>1 AND C=1) OR (B<>1 AND D=1)". Although in your case it would make no difference. You just don't normally see brackets in IF code until things get complex.

Cheers

I am 99% probably lying in bed right now... so don't blame me for crappy typing
Current fave quote : "She was like a candle in the wind.... unreliable...."
Dazzag
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Cyprus
Posted: 26th Aug 2007 10:55
Quote: "most people are too lazy to case cast the user's input"
Maybe so, but the vast majority of code I've seen (including a lot of business stuff) use uppercase checking compared with lowercase. I don't think I've ever used lowercase functions on anything else but formatting (eg. making a name or address look nice).

Cheers

I am 99% probably lying in bed right now... so don't blame me for crappy typing
Current fave quote : "She was like a candle in the wind.... unreliable...."
Deathead
18
Years of Service
User Offline
Joined: 14th Oct 2006
Location:
Posted: 26th Aug 2007 12:58
Thanks Dazzag I was using spaces

Dazzag
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Cyprus
Posted: 26th Aug 2007 13:11
No worries. Bit of a guess that one. I was stuffed if it wasn't that

Cheers

I am 99% probably lying in bed right now... so don't blame me for crappy typing
Current fave quote : "She was like a candle in the wind.... unreliable...."

Login to post a reply

Server time is: 2024-11-26 11:53:25
Your offset time is: 2024-11-26 11:53:25