Jump to content

New to MSFN and in need of some batch help.


Recommended Posts

===== Post Nº 1 =====

Well, I've been making a simple program with a friend or too just to pass around to the computers in school to entertain and I was in the process of debugging when an error occurred. Well, I would select a choice, and it would close. I will show you the code I'm using.


@echo off
title click on this QUIZ
color f0
echo WELCOME!
echo We, the programmers of the famous "Click on this" have
echo created a questionaire to see what YOU the user wants!
echo Yes! That's right! YOU! YOU! YOU!
echo It's quite simple. And maybe fun?echo All you need to do is answer 5 questions with a 1,2,3,or 4.echo Ready?!
echo Lets go! Press any key to begin.
pause >nul
cls
echo Question A. What would you like to see in the next "Click on this"?
echo 1. More interactive features
echo 2. I DON'T WANT TO SEE ANY MORE! IT SUCKS! (?)
echo 3. More humor (Is it possible?)
echo 4. More interesting features
set choice=
set /p choice=Select a number from above:
if not '%choice%'==" set choice=%choice:~0,1%
if '%choice%'=='1' goto A
if '%choice%'=='2' goto A
if '%choice%'=='3' goto A
if '%choice%'=='4' goto A
:A
echo Question B.

I don't see any problem, but of course I'm just a nooby VB2005 programmer (and not that great at all).

PROBLEM SOLVED! I changed '%choice%' to '%var%' and I took out "set choice=" and it works perfectly!

===== Post Nº 2 =====

Well, after a couple gummy worms and some headaches, its COMPLETE!

@echo off
title click on this QUIZ
color f0
echo WELCOME!
echo We, the programmers of the famous "Click on this" have
echo created a questionaire to see what YOU the user wants!
echo Yes! That's right! YOU! YOU! YOU!
echo It's quite simple. And maybe fun?
echo All you need to do is answer 2 questions with a 1,2,3,or 4.
echo Ready?!
echo Lets go! Press any key to begin.
pause >nul
cls
echo Question A. What would you like to see in the next "Click on this"?
echo 1. More interactive features
echo 2. I DON'T WANT TO SEE ANY MORE! IT SUCKS! (?)
echo 3. More humor (Is it possible?)
echo 4. More interesting features
set /p var= Please choose 1,2,3, or 4.
if '%var%'=='1.' goto A
if '%var%'=='2.' goto A
if '%var%'=='3.' goto A
if '%var%'=='4.' goto A
:A
cls
echo You chose option '%var%'
pause
cls
echo Question B.
echo What don't you like about "Click on this"?
echo 1. The stupid typing (I personaly hate it.)
echo 2. The non-interactiveness (is that a word?)
echo 3. The difficulty of use?
echo 4. The people who made it....
set /p aar= Please choose 1,2,3, or 4.
if '%aar%'=='1.' goto B
if '%aar%'=='2.' goto B
if '%aar%'=='3.' goto B
if '%aar%'=='4.' goto B
:B
cls
echo You chose '%aar%'
pause
cls
Echo Thank you for taking this quiz.
echo It will surely aid in our decision making process in "Click on this v2.0"
echo.
echo..
echo...
echo....
echo...
echo..
echo.
echo Just one more question.
set /p bar= If you do not wish to answer the folowing question, type "no" (WARNING: Case sensative so make sure you put "no"
if '%bar%' == 'no' GOTO :end
if '%bar%' == 'yes' GOTO :C
:C
cls
echo Was this quiz easy to use?

set /p dar= Type "yes" or "No"
if '%dar%' == 'yes' GOTO D
if '%dar%' == 'no' GOTO D
:D
:end
cls
Echo Thank you for taking this quiz.
Echo Press any key to exit.
pause >nul

It's almost completely bug free!

Edited by Yzöwl
Link to comment
Share on other sites


I have made a few changes to your script which I hope may help you a little. They are really methods of making sure that incorrect or inappropriate answers are not given to your questions or that the script isn't mistreated in running.

You very likely will not understand it all but with a little research and possibly a few questions you should quickly improve your script thought processes.

@Echo off
Setlocal
Title Click on this QUIZ
Color f0
Mode 72,12
Echo WELCOME!
Echo We, the programmers of the famous "Click on this" have
Echo created a questionaire to see what YOU the user wants!
Echo Yes! That's right! YOU! YOU! YOU!
Echo It's quite simple. And maybe fun?
Echo All you need to do is answer 2 questions with a 1,2,3,or 4.
Echo Ready?!
Echo Lets go!
Pause
:A
Cls
Set "aar="
Echo Question A.
Echo What would you like to see in the next "Click on this"?
Echo 1. More interactive features
Echo 2. I DON'T WANT TO SEE ANY MORE! IT SUCKS! (?)
Echo 3. More humor (Is it possible?)
Echo 4. More interesting features
Set /p "aar= Please choose 1,2,3, or 4. "
If Not Defined aar Goto A
If %aar% Geq 1 (If %aar% Leq 4 (
Cls
Echo You chose option '%aar%'
Pause
Goto B))
Goto A
:B
Cls
Set "bar="
Echo Question B.
Echo What don't you like about "Click on this"?
Echo 1. The stupid typing (I personaly hate it.)
Echo 2. The non-interactiveness (is that a word?)
Echo 3. The difficulty of use?
Echo 4. The people who made it....
Set /p "bar= Please choose 1,2,3, or 4. "
If Not Defined bar Goto B
If %bar% Geq 1 (If %bar% Leq 4 (
Cls
Echo You chose option '%bar%'
Pause
Goto Next))
Goto B
:Next
Cls
Set "var="
Echo Thank you for taking this quiz.
Echo It will surely aid in the "Click on this v2.0" decision making process.
Echo..
Echo...
Echo....
Echo.....
Echo....
Echo...
Echo..
Echo Just one more question.
Set /p "var= Do you wish to answer it? [Yes|No]: "
If Not Defined var Goto Next
If /i %var% Equ Yes Goto C
Goto End
:C
Cls
Set "car="
Echo Question C.
Set /p "car= Was this quiz easy to use? [Yes|No]: "
If Not Defined car Goto C
If /i %car:~0,1% Neq Y (
If /i %car:~0,1% Equ N (Echo Sorry to here that!) Else (Goto C)
) Else (Echo Glad to here it!)
Ping -n 4 127.0.0.1>Nul
:End
Cls
Echo Thank you for taking this quiz.
Echo Press any key to exit.
Pause>Nul

PS Please use the edit facility to append to your previous post if nobody else has replied since posting it and try to use code tags too!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...