# Simple programming help

## Recommended Posts

Well, I recently bought Game Programming for Teens which teaches you the language BlitzPlus. Everything so far has been easy to understand, yet when I attempted something of my own, it didn't work. My code is to generate a simple input/output procedure, just like that of an old DOS adventure game. So far the only input I can make which will make a response is a number. I'm trying to make it so that you can enter a line of text, or String$, as a choice. Here is my code: answer = Input$("you find yourself in a room with a cat. what will you do?") If answer = "pet cat" Then Print "You pick up the cat. The cat bites your face off. You are Dead." ElseIf answer = "kick the cat" Then Print "You kick the cat. The cat runs away crying. You win." EndIf Delay 10000 When the program loads and I put in my answer, nothing happens. I tried using String$instead of Input$ for the answer variable, but that doesn't work. I know this may seem like a pathetic problem, and I'm sure I will learn how solve it as I progress in the book, but for now I'd like to get a quick response. -Thanks! [Edited by - Taran Shiro on June 2, 2007 1:14:05 PM]

##### Share on other sites
Never heard of the language "BlitzPlus", though it does look a bit like BASIC.

I would guess that your tests (i.e. "If answer =") are wrong. It depends on what the "=" does, one would guess.

It may also be that what you input isn't what the variable is being set to. It may be including a carriage return at the end, for instance.

Without knowing the syntax of "BlitzPlus" it's hard to say.

For a simple debugging step, try:

right after the input and see if it looks the same. Beyond that you'll just have to study the syntax of that language some more.

##### Share on other sites
Actually just a little Google search turned up this:

http://www.blitzmax.com/bpdocs/command.php?name=If&ref=2d_cat

; IF THEN Example; Input the user's namename$=Input$("What is your name? "); Doesn't the person's name equal SHANE?If name$= "Shane" ThenPrint "You are recognized, Shane! Welcome!"ElsePrint "Sorry, you don't belong here!"; End of the condition checkingEnd If Seems you need to change your code to ... answer$ = Input$("you find yourself in a room with a cat. what will you do?") If answer$ = "pet cat" Then
Print "You pick up the cat. The cat bites your face off. You are Dead."

ElseIf answer$= "kick the cat" Then ... You were missing the "$" at the end of your variable name.

## Create an account

Register a new account

• ### Forum Statistics

• Total Topics
627736
• Total Posts
2978866

• 10
• 10
• 21
• 14
• 12