1.

Solve : chatting with CMD?

Answer»

hey guys
I'm trying to make a little CMD fun thing
I'm gonna add bunch of words and so it can reply to the user
OK

for ex, what command do i use for IF the user said blah or something, EX:
Code: [Select]IF hello=hello mate
IF what it is your name=Ashely, whats yours?
(ok right here, i need to put something that what ever the user says, it would reply back: cool name)
so u get the idea?
all those commands are wrong, i know, its what i need help with
i was looking hours for the right command to use, FIRST i thought choice, but then 1%
idk, helpp?

BTW please just don't reply: check the IF /? command
put this as an EXAMPLE:
Code: [Select]IF hello=hello mate
IF what it is your name=Ashely, whats yours?
(ok right here, i need to put something that what ever the user says, it would reply back: cool name)
out it in the right codes, and I'll get the right idea
thanks
how about...

Code: [Select] @echo off
echo What is your name?
set /p name=
echo welcome %name% cool name...

FBQuote from: fireballs on August 16, 2008, 05:17:00 AM

how about...

Code: [Select] @echo off
echo What is your name?
set /p name=
echo welcome %name% cool name...

FB
thanks, but thats only part of it
i need the user to start talking

so if they said Hi:
Hello
USER: What is your name?:
Ashely, and u?
set /p name=
echo %name% cool name...
echo so %name% hows ur day?
IF bad GOTO bad
IF good goto good

:bad
echo why?
(what ever they said here, it will reply Im sorry)


The PROBLEM with IF is that the user has an unlimited range of RESPONSES, choice might be better like so...

Code: [Select]Choice /N /C "GBA" /M "How was your day? Good? (G) Bad? (B) Alright? (A)"
if errorlevel 2 goto Label1
if errorlevel 3 goto Label2
if errorlevel 4 goto Label3
rem code here...

FBQuote from: fireballs on August 16, 2008, 05:30:43 AM
The problem with IF is that the user has an unlimited range of responses, choice might be better like so...

Code: [Select]Choice /N /C "GBA" /M "How was your day? Good? (G) Bad? (B) Alright? (A)"
if errorlevel 2 goto Label1
if errorlevel 3 goto Label2
if errorlevel 4 goto Label3
rem code here...

FB
ok, so far i got this:
Code: [Select]title Chat with CMD
@echo OFF
cls

echo Hello mate, what is your name?
echo What is your name?
set /p name=
echo welcome %name% cool name...
Choice /N /C "GBA" /M "How was your day? Good? (G) Bad? (B) Alright? (A)"
if errorlevel 2 goto Label1
if errorlevel 3 goto Label2
if errorlevel 4 goto Label3

:Label1
cls
echo why awesome?

:Label2
cls
echo why badd?

:Label3
cls
echo alright?
echo sounds like something is going on

pausebut it doesn't work at the choice, something wrong?what do you mean doesn't work? i might have gotten the errorlevels wrong try debugging...

Code: [Select]choice...blah blah

echo %errorlevel%sorry for some reason i skipped a number it should just be...

Code: [Select]choice...
if errorlevel 1 goto good
if errorlevel 2 goto bad
if errorlevel 3 goto alriteQuote from: fireballs on August 16, 2008, 05:55:55 AM
sorry for some reason i skipped a number it should just be...

Code: [Select]choice...
if errorlevel 1 goto good
if errorlevel 2 goto bad
if errorlevel 3 goto alrite
soo this:
Quote
title Chat with CMD
@echo OFF
cls

echo Hello mate, what is your name?
echo What is your name?
set /p name=
echo welcome %name% cool name...
Choice /N /C "GBA" /M "How was your day? Good? (G) Bad? (B) Alright? (A)"


if errorlevel 1 goto good
if errorlevel 2 goto bad
if errorlevel 3 goto alrite
:1
cls
echo why awesome?

:2
cls
echo why badd?

:3
cls
echo alright?
echo sounds like something is going on

pause

it suddently closes ok this works:Quote
title Chat with CMD
@echo OFF
cls

echo Hello mate, what is your name?
echo What is your name?
set /p name=
echo welcome %name% cool name...
pause
cls
ECHO so hows your day?
ECHO.
ECHO 1. Good
ECHO 2. Alright
ECHO 3. BAD
set choice=
set /p choice=
if not '%choice%'=='' set choice=%choice:~0,1%
if '%choice%'=='1' goto :1
if '%choice%'=='2' goto :3
if '%choice%'=='3' goto :2
ECHO "%choice%" is not valid please try again
:1
cls
echo why awesome?

:2
cls
echo why badd?

:3
cls
echo alright?
echo sounds like something is going on

pause
he is probably using XP and you Vista.
XP doesnt have choice.exe but Vista does thats the problem i think


Discussion

No Comment Found