Issue

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
1+2=46
Posts: 25
Joined: 23 Mar 2010 14:19

Issue

#1 Post by 1+2=46 » 01 May 2010 18:52

Hi, there.


I am trying to make a chat in batch language, which I'm almost done.
But there's an issue: whenever I run the file, it asks me twice the same choice (choice made by me).


Here is the full code:

@echo off
Cls
Set LINE=0
For /F "delims=" %%L in (Settings.ini) do (
Set /A LINE += 1
If "!LINE!" == "4" (
Set STR=%%L
Echo.!STR:~11!> %TEMP%.\T1.DAT
Findstr /I /B /C:" " %TEMP%.\T1.DAT > nul
Del %TEMP%.\T1.DAT
)
If /I !STR:~11!==red set bc=C
If /I !STR:~11!==green set bc=A
If /I !STR:~11!==blue set bc=9
If /I !STR:~11!==yellow set bc=E
If /I !STR:~11!==black set bc=0
If /I !STR:~11!==white set bc=F
)
Cls
Set LINE=0
For /F "delims=" %%L in (Settings.ini) do (
Set /A LINE += 1
If "!LINE!" == "3" (
Set STR=%%L
Echo.!STR:~11!> %TEMP%.\T1.DAT
Findstr /I /B /C:" " %TEMP%.\T1.DAT > nul
Del %TEMP%.\T1.DAT
)
If /I !STR:~11!==red set fc=C
If /I !STR:~11!==green set fc=A
If /I !STR:~11!==blue set fc=9
If /I !STR:~11!==yellow set fc=E
If /I !STR:~11!==black set fc=0
If /I !STR:~11!==white set fc=F
)
If not defined bc set bc=0
If not defined fc set fc=C
Color %bc%%fc%
Cls
Title Chat
Cls

:Start
Mode con cols=40 lines=15
Call :Clear
Echo.
Echo Hello and welcome to Chat
Echo.
Echo.
Echo.
Echo.
Echo Select an option:
Echo.
Echo.
Echo 1 - Join chat
Echo 2 - Exit
Echo.
Set /P input=
Call :Clear
If %input%==1 goto Startchat
If %input%==2 goto Exit
Goto Start

:Startchat
Set chat=Chat
Find /V /I " " < "%cd%\%chat%.txt" > "%cd%\%chat%.txt"
Goto Showchat

:Showchat
Call :Clear
If not exist "%cd%\Settings.ini" (
Echo There is no chat name defined.
Ping localhost -n 3 -w 1000 >nul
Exit
Cls
)
If "%1"=="Goto" goto %2
%comspec% /V:ON /C %0 Goto Continue1
Goto :eof

:Continue1
Cls
Set LINE=0
For /F "delims=" %%L in (Settings.ini) do (
Set /A LINE += 1
If "!LINE!" == "2" (
Set STR=%%L
Echo.!STR:~5!> %TEMP%.\T1.DAT
Findstr /I /B /C:" " %TEMP%.\T1.DAT > nul
Type %TEMP%.\T1.DAT
Del %TEMP%.\T1.DAT
)
Set name=!STR:~5!
)

Echo %name% has joined the chat.>>"%cd%\%chat%.txt"
Mode con cols=60 lines=22
Start Input.bat

:Loop
Cls
If exist "%cd%\%chat%.txt" type "%cd%\%chat%.txt"
If not exist "%cd%\%chat%.txt" (
Exit
Cls
)
Echo.
Echo.
Echo.
Echo.
Echo.
Echo.
Echo.
Echo.
Echo.
Echo.
Echo.
Echo.
Ping localhost -n 2 -w 1000 >nul
Goto Loop

:Clear
Cls
Goto :eof

:Exit
Exit
Cls


Thank you in advance.


EDIT:
I just discovered now that if the file Settings.ini doesn't exist, it doesn't asks me to choice twice.

Maybe try to create a file named Settings.ini in the same folder and see if it works.
Last edited by 1+2=46 on 01 May 2010 20:37, edited 1 time in total.

phillid
Posts: 109
Joined: 03 Apr 2010 20:27
Location: Wellington, New Zealand
Contact:

Re: Issue

#2 Post by phillid » 01 May 2010 20:18

It's a nice script. A few minor typos - 'Select a option' should be 'Select an option' :D . I'm still working on why it shows the message twice... maybe it can't handle the input on the first time... I'll get back to you!! :D

1+2=46
Posts: 25
Joined: 23 Mar 2010 14:19

Re: Issue

#3 Post by 1+2=46 » 01 May 2010 20:35

phillid wrote:It's a nice script. A few minor typos - 'Select a option' should be 'Select an option' :D . I'm still working on why it shows the message twice... maybe it can't handle the input on the first time... I'll get back to you!! :D


Ok. Thank you.

And everyone does mistakes. :D
I could tell you why that sentence was misspelled, but that would destroy my reputation. :D

Post Reply