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.