Author Topic: Question about a question  (Read 1269 times)

0 Members and 1 Guest are viewing this topic.

Offline bailey96

  • ZX 81
  • *
  • Posts: 2
  • Karma: 1
    • View Profile
Question about a question
« on: December 17, 2012 »
Hi, New to this and just wanted to know how to add a question into yabasic
please see example.
Code: [Select]
Print "welcome user"
sleep (5)
print "what is your name"
input a
if a=james
goto 1
//what goes here? to stop it if its wrong ?
1
thanks James

Offline rain_storm

  • Here comes the Rain
  • DBF Aficionado
  • ******
  • Posts: 3088
  • Karma: 182
  • Rain never hurt nobody
    • View Profile
    • org_100h
Re: Question about a question
« Reply #1 on: December 21, 2012 »
When you say question do you mean using the input command or using if then else statements? Maybe this example will clear things up a little

Code: [Select]
rem this is a string input
print "Hello my name is yabasic"
input "What is your name?" Name$
print "Hello " + Name$ + " nice to meet you"

rem this is a numeric input
print "So " + Name$ + " can you answer this question for me"
print "I have 3 apples and I share 1 of my apples with you"
input "How many apples do I have left?" NumApples

if (NumApples = 2) then
    print "Correct " + Name$ + " I have exactly 2 apples left."
elsif (NumApples < 2) then
    print "No " + Name$ + " I have 2 apples left."
elsif (NumApples > 2) then
    print "No " + Name$ + " I have 2 apples left."
else
    print "No " + Name$ + " I have 2 apples left."
endif


Challenge Trophies Won:

Offline bikemadness

  • Amiga 1200
  • ****
  • Posts: 261
  • Karma: 25
  • Hard players don't go home.
    • View Profile
Re: Question about a question
« Reply #2 on: January 15, 2013 »
If James's example is literally correct,
it's something I've wanted to know.
How do you match letters?
If any name is inputted, it will go to 1.

All I've come up with is reverting to chr$

Code: [Select]
'right answer is VANCE
Print "welcome user"
pause 1
label again
print "what is your name"
input a$
if a$=chr$(86)+chr$(65)+chr$(78)+chr$(67)+chr$(69) print "right"
if a$<>chr$(86)+chr$(65)+chr$(78)+chr$(67)+chr$(69) goto again
print
print chr$(86);
print chr$(65);
print chr$(78);
print chr$(67);
print chr$(69)
« Last Edit: January 15, 2013 by bikemadness »
Have a Yahappy day.
I don't know what is wrong with the world - but I know how to fix it.