Loop crash

September 15, 2011 at 08:32:25
Specs: Windows XP
Hello all! I am on the tail end of a chat program I have created from a batch file. Everything is working great with the small exception that my loop closes randomly. There is quite a bit of code involved in this so I am just going to post the loop portion.

:message
title Type
mode con cols=45 lines=3
set /p msg=Chat:
echo %time% - %name%: %msg% >> %room%.crm
goto message

How it works is this code snipet is a seprate batch file that acts as the input. I have another batch that acts as the output. The output portion works fine but after entering a few lines in the input it closes....I cannot figure it out. Any help would be greatly appreciated. Thank you


See More: Loop crash

Report •


#1
September 15, 2011 at 09:03:21
Posted script works fine for me.

How To Ask Questions The Smart Way


Report •

#2
September 15, 2011 at 09:07:29
Thank you razor for the fast reply. I have tested this on multiple pc's with multiple os's but it always does the same thing. It does not do it when I run the script by itself.?.? One is for reading a file and the other is for writing the same file, could that cause a crash?

Report •

#3
September 15, 2011 at 09:19:29
If it helps here's the full code


input.bat

@echo off
Title Main Menu
Color F0
mode con cols=45 lines=10

:name
set /p name=Enter Your Name:

:menu
echo 1. Create New?
echo 2. Join Existing?

:choices
set /p choice=
if "%choice%"=="1" goto new
if "%choice%"=="2" goto old

:new
title new room
set /p room=Name Your Room:
echo %room% >> rooms.crm
echo Welcome To %room% >> %room%.crm
goto start

:old
title Join Room
cls
echo Rooms To Choose From:
type rooms.crm
echo.
set /p room=Which Room Would You Like To Join?
goto start

:start
cls
echo %name% has joined >> %room%.crm
start ouput.bat
goto message

:message
title Type
mode con cols=45 lines=3
set /p msg=Chat:
echo %time% - %name%: %msg% >> %room%.crm
if %msg%==cls goto clean
goto message

:clean
del %room%.crm
goto message

output.bat

@echo off
Title Chat
color f0
mode con cols=45 lines=50
set /a max=50

:start
set /a counter+=1
echo %counter% > nul
if %counter%==%max% goto display
goto start

:refresh
set /a counter=0
goto start

:display
cls
type %room%.crm
goto end


Report •

Related Solutions

#4
September 15, 2011 at 11:52:10
So after some tinkering with it I changed the input batch and changed "if %msg%==cls goto clean" to "if %msg%==cls del room.crm" this seems to have fixed the issue. Thanks again Razor for the quick response.

Report •

#5
September 15, 2011 at 12:24:59
Chat:asdf asdf
asdf==cls was unexpected at this time.

Nope, still broken.

How To Ask Questions The Smart Way


Report •

#6
September 15, 2011 at 12:53:37
Im not sure how you got that error. After I did my last post I sent it to a few computers on the network to test it and we have been using it just fine.

Report •


Ask Question