1.

Solve : Batch random answer??

Answer»

How can I make a batch that GIVES a random answer?
for example
echo (hi or hello or wazza)
 
I am also wondering about something like that:
set /p chat=
IF /I "%chat%" (is containing pf and nothing else)
ECHO bored? Quote

How can I make a batch that gives a random answer?

This should help you get started. It will probably work better with more answers. Use ctl+C to end execution. Note: intHighNumber must equal the number of answers for this to work correctly.

Code: [Select]echo off
setlocal

set intLowNumber=1
set intHighNumber=3

set ans.1=I am fine
set ans.2=I am lousy
set ans.3=I am indifferent

:loop
  echo How Are You TODAY?
  set /a rnd=%random% %% (%intHighNumber% - %intLowNumber% + 1) + %intLowNumber%
  call echo %%ans.%rnd%%%
  ping -N 3 localhost > nul
  goto loop

Quote
IF /I "%chat%" (is containing pf and nothing else)
ECHO bored?

if "%chat%"=="pf" echo bored? 

Not using the /i switch requires an exact match for the condition to be true (pf==pf). Using the /i switch make the comparison case insensitive (pf==PF)

 hey thx, you really UNDERSTAND these things


Discussion

No Comment Found