Welcome, guest | Sign In | My Account | Store | Cart
@ECHO off
REM MessengerMain.bat
TITLE Messanger Setup
SET /p name= Name: 

:addressChoice
ECHO.
ECHO  Enter one of the numbers below
ECHO.
ECHO  1. Use current address
ECHO  2. Enter a new address
ECHO.
SET /p newAddress= Choice? 
IF %newAddress%==1 (
SET address=C:\Users\Dad\Documents\School\BatchMSG\MSGFolder
GOTO mainPart
)
IF %newAddress%==2 GOTO addressLoop
IF %newAddress% GTR 2 (
CLS
ECHO ERROR: Enter either 1 or 2
GOTO addressChoice
)
IF %newAddress% LSS 1 (
CLS
ECHO Enter either 1 or 2
GOTO addressChoice
)

:addressLoop
SET /p address= Address: 
IF NOT EXIST %address% (
ECHO  Please enter a valid address
GOTO addressLoop
)

:mainPart
CLS
ECHO  This is a list of all current conversations in %address%:
ECHO.
DIR %address% /B | FIND ".txt"
ECHO.
ECHO  You may choose an existing filename from the list above
ECHO  or enter a new filename
ECHO.
SET /p convoDest= Enter Filename: 

ECHO %address%\%convoDest% > Address.txt
ECHO %name% > Name.txt
IF NOT EXIST %address%\%convoDest% (
ECHO. 2>%address%\%convoDest%
)

START Receiver.bat
START Sender.bat
------------------------------
@ECHO off
REM Receiver.bat
FOR /f %%a IN (Address.txt) DO (
SET address=%%a
)
FOR /f "usebackq delims=" %%a IN (Name.txt) DO (
SET name=%%a
)
TITLE Receiver: %name% - %address%
SET /a counterOld=0

:mainReader
SET /a counter=0
IF NOT EXIST %address% (
ECHO Somebody has deleted the conversation
PAUSE
EXIT
)
FOR /f %%a IN (%address%) DO (
SET /a counter+=1
)
IF NOT %counter%==%counterOld% ( 
CLS
TYPE %address%
COLOR FC
PING 1.1.1.1 -n 1 -w 800 >NUL
COLOR 07
SET /a counterOld=%counter%
)
GOTO mainReader
------------------------------
@ECHO off
REM Sender.bat
FOR /f %%a IN (Address.txt) DO (
SET address=%%a
)
FOR /f "usebackq delims=" %%a IN (Name.txt) DO (
SET name=%%a
)
DEL Address.txt
DEL Name.txt
TITlE Sender: %name% - %address%
ECHO  Enter /cls to clear the conversation
ECHO  Enter /del to delete the conversation
ECHO.

:mainPart
SET /p msg= Message: 
@ECHO %name%: %msg%>>%address%
IF "%msg%"=="/cls" (
ECHO. 2>%address%
)
IF "%msg%"=="/del" (
DEL %address%
CLS
ECHO You have ended the conversation
PAUSE
EXIT
)
CLS
GOTO mainPart

Diff to Previous Revision

--- revision 2 2012-02-02 03:18:52
+++ revision 3 2012-02-03 01:41:41
@@ -2,6 +2,8 @@
 REM MessengerMain.bat
 TITLE Messanger Setup
 SET /p name= Name: 
+
+:addressChoice
 ECHO.
 ECHO  Enter one of the numbers below
 ECHO.
@@ -14,6 +16,16 @@
 GOTO mainPart
 )
 IF %newAddress%==2 GOTO addressLoop
+IF %newAddress% GTR 2 (
+CLS
+ECHO ERROR: Enter either 1 or 2
+GOTO addressChoice
+)
+IF %newAddress% LSS 1 (
+CLS
+ECHO Enter either 1 or 2
+GOTO addressChoice
+)
 
 :addressLoop
 SET /p address= Address: 
@@ -41,6 +53,37 @@
 
 START Receiver.bat
 START Sender.bat
+------------------------------
+@ECHO off
+REM Receiver.bat
+FOR /f %%a IN (Address.txt) DO (
+SET address=%%a
+)
+FOR /f "usebackq delims=" %%a IN (Name.txt) DO (
+SET name=%%a
+)
+TITLE Receiver: %name% - %address%
+SET /a counterOld=0
+
+:mainReader
+SET /a counter=0
+IF NOT EXIST %address% (
+ECHO Somebody has deleted the conversation
+PAUSE
+EXIT
+)
+FOR /f %%a IN (%address%) DO (
+SET /a counter+=1
+)
+IF NOT %counter%==%counterOld% ( 
+CLS
+TYPE %address%
+COLOR FC
+PING 1.1.1.1 -n 1 -w 800 >NUL
+COLOR 07
+SET /a counterOld=%counter%
+)
+GOTO mainReader
 ------------------------------
 @ECHO off
 REM Sender.bat
@@ -72,31 +115,3 @@
 )
 CLS
 GOTO mainPart
-------------------------------
-@ECHO off
-REM Receiver.bat
-FOR /f %%a IN (Address.txt) DO (
-SET address=%%a
-)
-FOR /f "usebackq delims=" %%a IN (Name.txt) DO (
-SET name=%%a
-)
-TITLE Receiver: %name% - %address%
-SET /a counterOld=0
-
-:mainReader
-SET /a counter=0
-IF NOT EXIST %address% (
-ECHO Somebody has deleted the conversation
-PAUSE
-EXIT
-)
-FOR /f %%a IN (%address%) DO (
-SET /a counter+=1
-)
-IF NOT %counter%==%counterOld% ( 
-CLS
-TYPE %address%
-SET /a counterOld=%counter%
-)
-GOTO mainReader

History