Benutzer-Werkzeuge

Webseiten-Werkzeuge


dos:cmdchat

cmdchat


script to build a little chat
need and using a tail-tool like tail.exe or baremetal to monitor the chat

Installation manual:

cmdchat.cmd
@echo off
call :clear_all_defined_vars
cls
set __a_vers__=0.1.16b
set __a_version__=Vers. %__a_vers__% 20.11.2008 Mark Wolfgruber

REM ############################################################
REM #
REM #   cmdchat.cmd
REM #
REM #
REM #  run from a share a little chat
REM #  using a tail-tool like baremetal to monitor the chat
REM #
REM # Installation:
REM #     please use the script install_cmdchat_server.cmd
REM #    or
REM # - create a Directory for the Script like:
REM #     md "c:\program files\script\cmdchat"
REM # - create a Directory for the Logfiles like:
REM #     md "c:\data\log\cmdchat"
REM # - create a share for the script and for the log like:
REM #     net share Data="%__a_datadir%" /UNLIMITED /REMARK:"Share for the data-log" /CACHE:None
REM #     net share cmdchat="%__a_prgdir%" /UNLIMITED /REMARK:"Share for the cmdchat-script" /CACHE:None
REM # - copy the files you are needed to the Program-directory like
REM #     copy cmdchat.cmd %Programfiles%\.
REM #     copy install_cmdchat.cmd %Programfiles%\.
REM #     copy tail.exe %Programfiles%\.
REM #     if you have not the tail.exe download it from http://unxutils.sourceforge.net
REM #     copy baretail.exe %Programfiles%\.
REM #     if you have not the baretail.exe download it from http://www.baremetalsoft.com
REM #
REM # - modify the variables __a_prg_dir__ and __a_chat_dir__
REM #   change 127.0.0.1 to your own server-ip-address
REM #
REM ############################################################
REM # Changelog:
Rem # - in future:
rem #  
REM # Vers. 0.1.16 20.11.2008 Mark Wolfgruber
rem # - edit chatroom/logfile/mainchat
rem # - monitor mainchat
REM # Vers. 0.1.15 20.11.2008 Mark Wolfgruber
rem # - fix bug " " "
REM # Vers. 0.1.14 19.11.2008 Mark Wolfgruber
rem # - bug u b - change user back
rem # - exit chat with chatname in mainchat
REM # Vers. 0.1.13 19.11.2008 Mark Wolfgruber
rem # - future
rem # - create usermanual
REM # Vers. 0.1.12 18.11.2008 Mark Wolfgruber
Rem # - for a better search and replace change the vars from
rem #   a_xxx and b_xxx to __a_xxx__ and __b_xxx__
rem # - list of varibales at the beginning
rem # - optimize setlocal  
rem # - if you are in an other chatroom, it display userchanges/login in the mainchat
REM # Vers. 0.1.11 18.11.2008 Mark Wolfgruber
Rem # L BUG and others
REM # Vers. 0.1.10 17.11.2008 Mark Wolfgruber
REM # - disply version number
REM # Vers. 0.1.9 17.11.2008 Mark Wolfgruber
REM # - add Installation and modify output parameters
Rem # - add to write/edit a textblock
rem # - repair bug purge "  " to " "
REM ############################################################
 
call :Date_German
 
:Vars
REM   ############################################################
REM   # please modify the following variables to your own server!
 
set __a_prg_dir__=\\127.0.0.1\cmdchat
 
set __a_chat_dir__=\\127.0.0.1\Data\log\cmdchat

REM   ############################################################
 
set __a_chat_name__=
if '%1'=='' (
    set __a_chat_name__=mainchat
  ) ELSE (
    set __a_chat_name__=%1
  )
set __a_str__=
if not "%__a_chat_name__%"=="" (
  set "__a_str__=%__a_chat_name__:.=_%"
  call :purge_input_os
  )
SET __a_chat_name__=%__a_str__%

REM   ### never use a "." in the prefix! ###
  set __a_prefix__=chat_%__a_Year__%-%__a_Month__%-%__a_Day__%
  set __a_extension__=txt.tail
  set __a_chat__=%__a_chat_dir__%\%__a_prefix__%.%__a_chat_name__%.%__a_extension__%
  set __a_mainchat__=%__a_chat_dir__%\%__a_prefix__%.mainchat.%__a_extension__%
REM   set __a_tail_dir__=C:\Progra~1\BareMetal
  set __a_tail_dir__=%__a_prg_dir__%
  set __a_tail_prg__=baretail.exe
 
  set __a_tail__=%__a_tail_dir__%\%__a_tail_prg__%
  SET __a_text__=new Chat
  SET __b_text__=new Chat

REM   define USERNAME
 
  set __a_str__=%USERNAME%
  call :purge_user
  set __a_user__=%__a_str__%
 
  set __a_last_lines__=15
 
  call :Time_German
  echo %__a_time__% %__a_user__%: ### User (%USERNAME%) enter the chat (%__a_chat_name__%) from %COMPUTERNAME% ###  >> %__a_chat__%
  if not "%__a_chat_name__%"=="mainchat" echo %__a_time__% %__a_user__%: ### User (%USERNAME%) start in the chat (%__a_chat_name__%) from %COMPUTERNAME% ###  >> %__a_mainchat__%
  echo.

rem if you don't want tail remark the folowing line
  if not exist %__a_tail_dir__%\tail.exe call :start_tail
rem  if not exist %__a_tail__% call :start_monitor
 
  goto help-mainmenu
 
 
:loop
  cls
  call :clear_vars
  echo ### CMDCHAT (%__a_vers__%) - Mainmenu ###    (type H to get help / E to End)
  echo active chat: %__a_chat_name__% %__a_chat__%
  echo my last Text: %__a_chat_text__%
  echo.
  call :display_last_lines
  echo.
:input
  SET /P __b_text__=new Text:
  set __b_text__>nul 2>&1 || (
    set __a_chat_text__=### no input ###
    goto loop
    )
  set __a_str__=
 set "__b_text__=%__b_text__:"=`%"
  if not "%__b_text__%"=="" (
    set "__a_str__=%__b_text__:&= !AND! %"
    call :purge_input_text
 
  ) ELSE (
    goto loop
  )
  set __b_text__=%__a_str__%
  if "%__b_text__%" == "" goto loop
  if "%__b_text__%" == " " goto loop
 
:new_text_aliases
  if "%__b_text__%" == "w" set __b_text__=W
  if "%__b_text__%" == "wt" set __b_text__=WT
  if "%__b_text__%" == "wn" set __b_text__=WN
  if "%__b_text__%" == "wd" set __b_text__=WD
  if "%__b_text__%" == "we" set __b_text__=WE
  if "%__b_text__%" == "t" set __b_text__=/T
  if "%__b_text__%" == "T" set __b_text__=/T
  if "%__b_text__%" == "/t" set __b_text__=/T
  if "%__b_text__%" == "/tm" set __b_text__=/TM
  if "%__b_text__%" == "m" set __b_text__=/M
  if "%__b_text__%" == "M" set __b_text__=/M
  if "%__b_text__%" == "/m" set __b_text__=/M
  if "%__b_text__%" == "/mm" set __b_text__=/MM
  if "%__b_text__%" == "c" set __b_text__=C
  if "%__b_text__%" == "u" set __b_text__=U
  if "%__b_text__%" == "p" set __b_text__=P
  if "%__b_text__%" == "b" set __b_text__=B
  if "%__b_text__%" == "a" set __b_text__=A
  if "%__b_text__%" == "l" set __b_text__=L
  if "%__b_text__%" == "e" set __b_text__=E
  if "%__b_text__%" == "h" set __b_text__=H
 
:new_text_options
  if "%__b_text__%" == "W" call :write_textblock & goto loop
  if "%__b_text__%" == "WT" call :write_textblock & goto loop
  if "%__b_text__%" == "WN" call :write_textblock & goto loop
  if "%__b_text__%" == "WD" call :write_textblock & goto loop
  if "%__b_text__%" == "WE" call :write_textblock & goto loop
  if "%__b_text__%" == "/T" call :start_tail & goto loop
  if "%__b_text__%" == "/TM" call :start_tail & goto loop
  if "%__b_text__%" == "B" call :change_to_busy & goto loop
  if "%__b_text__%" == "L" call :change_lines & goto loop
  if "%__b_text__%" == "A" goto list_chatlogs
  if "%__b_text__%" == "P" goto explore_chatlog
  if "%__b_text__%" == "U" goto change_user
  if "%__b_text__%" == "C" goto choose_chat
  if "%__b_text__%" == "/MM" goto start_monitor
  if "%__b_text__%" == "/M" goto start_monitor
  if "%__b_text__%" == "/EL" call :edit_chatroom_notepad & goto loop
  if "%__b_text__%" == "/EM" call :edit_mainchat_notepad & goto loop
  if "%__b_text__%" == "H" goto help-mainmenu
  if "%__b_text__%" == "E" goto end
 
:write_new_text    
  set __a_str__=
  if not "%__a_text__%"=="" (
    set "__a_str__=%__a_text__:&= !AND! %"
    call :purge_input_text
  )
  set __a_text__=%__a_str__%  
 
  set __a_str__=
  if not "%__b_text__%"=="" (
    set "__a_str__=%__b_text__:&= !AND! %"
    call :purge_input_text
  )
  set __b_text__=%__a_str__%
 
  if "%__b_text__%" == "%__a_text__%" goto loop
 
  set __a_text__=%__b_text__%
 
  call :Time_German
  set __a_chat_text__=%__a_time__% %__a_user__%: %__a_text__%
 
  cls
  echo %__a_chat_text__% >> %__a_chat__%
 
  goto loop
 
:choose_chat
  set __a_chat_text__=### Menu Change chatfile ###
  cls
REM  echo.
  echo ### CMDCHAT (%__a_vers__%) - change the chatfile ###
  echo  type B to change back to the mainchat  
  echo  type E to exit
  echo.
  echo available chats:
  FOR /F "usebackq tokens=1,2,3* delims=." %%a IN (`dir /b %__a_chat_dir__%\%__a_prefix__%.*.%__a_extension__%`) DO @echo    %%b
  echo.
  echo activ chat:
  echo    %__a_chat_name__%
  echo.
  set __b_chat_name__=%__a_chat_name__%
  SET /P __b_chat_name__=new Chat [%__a_chat_name__%]:  
    set __b_chat_name__>nul 2>&1 || goto choose_chat
  set "__a_str__=
  if not "%__b_chat_name__%"=="" (
    set "__a_str__=%__b_chat_name__:.=_%"
    call :purge_input_os
  )
  set __b_chat_name__=%__a_str__%
 
  if "%__b_chat_name__%" == "" goto choose_chat
  if "%__b_chat_name__%" == "e" goto loop
  if "%__b_chat_name__%" == "E" goto loop
  if "%__b_chat_name__%" == "b" set __b_chat_name__=mainchat
  if "%__b_chat_name__%" == "B" set __b_chat_name__=mainchat
  if "%__b_chat_name__%" == "h" goto help
  if "%__b_chat_name__%" == "H" goto help
 
  set __a_quest__=N
  SET /P __a_quest__=change Chat to %__b_chat_name__%, sure? [Y/(N)]:
    set __a_quest__>nul 2>&1 || goto choose_chat
  if "%__a_quest__%" == "y" set __a_quest__=Y
  if not "%__a_quest__%" == "Y" goto loop
 
  call :Time_German
  echo %__a_time__% %__a_user__%: ### User (%USERNAME%) change to chat (%__b_chat_name__%) ### >> %__a_chat__%
  set __a_chat__=%__a_chat_dir__%\%__a_prefix__%.%__b_chat_name__%.%__a_extension__%
  echo %__a_time__% %__a_user__%: ### User (%USERNAME%) enter the chat (%__b_chat_name__%) from %COMPUTERNAME% ### >> %__a_chat__%
 
  if not "%__a_chat_name__%"=="mainchat"  (
    if not "%__b_chat_name__%"=="mainchat"  (
      echo %__a_time__% %__a_user__%: ### User ^(%USERNAME%^) change from chat ^(%__a_chat_name__%^) to chat ^(%__b_chat_name__%^) ###  >> %__a_mainchat__%
    )
  )
 
  set __a_chat_name__=%__b_chat_name__%
 
  goto loop
 
 
:change_to_busy  
  call :Time_German
  echo %__a_time__% %__a_user__%: ### User (%USERNAME%) is *** busy *** at the moment, User standby... ### >> %__a_chat__%
  if not "%__a_chat_name__%"=="mainchat"  echo %__a_time__% %__a_user__%: ### User (%USERNAME%) is *** busy *** at the moment, User standby in the the chat (%__a_chat_name__%)###   >> %__a_mainchat__%
 
  cls
  echo ### CMDCHAT (%__a_vers__%) - change in a busy state ###
  echo.
  echo You are busy since %__a_time__%
  echo to come back to the chat (%__a_chat_name__%)
  echo.
  pause
 
  call :Time_German
  echo %__a_time__% %__a_user__%: ### User (%USERNAME%) is back again ### >> %__a_chat__%
  if not "%__a_chat_name__%"=="mainchat"  echo %__a_time__% %__a_user__%: ### User (%USERNAME%) is back in the the chat (%__a_chat_name__%) again ###   >> %__a_mainchat__%
 
  goto :EOF
 
:change_user
  set __a_chat_text__=### Menu Change Username ###
  cls
  echo ### CMDCHAT (%__a_vers__%) - change the username ###
  echo    type B to change back to the original username (%USERNAME%)
  echo    type E to exit
  echo    Username with max 8 characters
  echo.
  echo activ user: %__a_user__%
  set __b_user__=%__a_user__%
  SET /P __b_user__=new Username [%__a_user__%]:
    set __b_user__>nul 2>&1 || goto change_user
  set "__a_str__=%__b_user__:?=_%"
  call :purge_input_os
  set __b_user__=%__a_str__%

  rem if "%__b_user__%" == "" goto change_user
  if "%__b_user__%" == "e" goto loop
  if "%__b_user__%" == "E" goto loop
  if "%__b_user__%" == "h" goto help
  if "%__b_user__%" == "H" goto help
  if "%__b_user__%" == "b" set __b_user__=%USERNAME%
  if "%__b_user__%" == "B" set __b_user__=%USERNAME%
 
  set "__a_str__=%__b_user__:?=_%"
  call :purge_user
  set __b_user__=%__a_str__%
 
  set __a_quest__=N
  SET /P __a_quest__=change Username to [%__b_user__%], sure? [Y/(N)]:
    set __a_quest__>nul 2>&1 || goto change_user
  if "%__a_quest__%" == "y" set __a_quest__=Y
  if not "%__a_quest__%" == "Y" goto loop
  call :Time_German
  echo %__a_time__% %__b_user__%: ### User %USERNAME% with Username (%__a_user__%) change to (%__b_user__%) ### >> %__a_chat__%
if not "%__a_chat_name__%"=="mainchat"  echo %__a_time__% %__b_user__%: ### User %USERNAME% with Username (%__a_user__%) change to (%__b_user__%) ### >> %__a_mainchat__%
  set __a_chat_text__=### Change Username from %__a_user__% to %__b_user__% ###
 
  set __a_user__=%__b_user__%
  goto loop
 
:start_monitor
  set __a_chat_text__=### Start Monitoring Logfile with ext. Tail-Program ###
 
  if not exist %__a_tail__% (
    echo.
    echo ### ERROR ###
    echo.
    echo %__a_tail__% not found
    echo.
    echo please install a Tail-Program like Baretail
    echo [download: http://www.baremetalsoft.com]
    echo and copy the file to %__a_tail__%
    echo.
    pause
  ) ELSE (
    if "%__b_text__%" == "/MM" (
      start "Tail" %__a_tail__% %__a_mainchat__%
    ) ELSE (
      start "Tail" %__a_tail__% %__a_chat__%
    )
  )
  goto loop
 
:start_tail
  set __a_chat_text__=### Start Monitoring Logfile with tail.exe ###
 
  if not exist %__a_tail_dir__%\tail.exe (
    echo.
    echo ### ERROR ###
    echo.
    echo %__a_tail__% not found
    echo.
    echo please install the tail.exe from the UnxUtils
    echo [download: http://unxutils.sourceforge.net]
    echo and copy the file to %__a_tail_dir__%\tail.exe
    echo.
    set __a_chat_text__=### ERROR: %__a_tail__% not found  ###
    pause
  ) ELSE (
    if "%__b_text__%" == "/MM" (
      start "Tail" %__a_tail_dir__%\tail.exe %__a_mainchat__%
    ) ELSE (
      start cmd.exe /c %__a_tail_dir__%\tail.exe -f %__a_chat__%
    )
  )
 
  if exist %__a_tail__% set __a_chat_text__=### Start tail.exe, use m to monitor with external Tailprogram ###
 
  goto :EOF
 
:explore_chatlog
  set __a_chat_text__=### Start Explorer ###
 
  start "Explorer" %windir%\explorer.exe /n, /e, %__a_chat_dir__%
 
  goto loop
 
:list_chatlogs
  set __a_chat_text__=### list all chats from today ###
  cls
REM  echo.
  echo ### CMDCHAT (%__a_vers__%) - list of all chats from today ###
  echo In the Mainmenu type C and then in the change menu type the chat you want to go  
  echo.
  FOR /F "usebackq tokens=1,2,3* delims=." %%a IN (`dir /b %__a_chat_dir__%\%__a_prefix__%.*.%__a_extension__%`) DO @echo %%b
  echo.
  pause
  goto loop
 
 
:change_lines
  set __a_chat_text__=### Menu Change lines ###
    cls
REM echo.
    echo ### CMDCHAT (%__a_vers__%) - change the number of lines to display with tail ###
 
  if not exist %__a_tail_dir__%\tail.exe (
      call :start_tail
      goto :EOF
    )
  echo    type E to exit
  echo.
  echo actual number of lines: %__a_last_lines__%
  set __b_last_lines__=%__a_last_lines__%
  SET /P __b_last_lines__=number of lines [%__a_last_lines__%]:
      set __b_last_lines__>nul 2>&1 || goto change_lines
 
  set "__a_str__=%__b_last_lines__:.=_%"
  call :purge_input_os
  set __b_last_lines__=%__a_str__%
 
  if "%__b_last_lines__%" == "" goto :EOF
  if "%__b_last_lines__%" == "e" goto :EOF
  if "%__b_last_lines__%" == "E" goto :EOF
  if "%__b_last_lines__%" == "h" echo no help available at the moment & goto :EOF
  if "%__b_last_lines__%" == "H" echo no help available at the moment & goto :EOF
 
  set /A __b_last_lines__=%__b_last_lines__%+0
  if "%__b_last_lines__%" == "0" set __b_last_lines__=1
  set __a_chat_text__=### Change displayed lines from %__a_last_lines__% to %__b_last_lines__% ###
  set __a_last_lines__=%__b_last_lines__%
  goto :EOF
 
:help
   cls
 
  set __a_chat_text__=### CMDCHAT (%__a_vers__%) - HELP ###

REM   echo.
  echo ### CMDCHAT (%__a_vers__%) - HELP ###
  echo.
  echo No helpmenu availabel at the moment for this menu
  echo.
  pause
  goto loop
 
:help-mainmenu
  cls
REM   echo.
  echo ### CMDCHAT (%__a_vers__%) - HELP ###
  echo %__a_version__%
REM   echo.
  echo start the chat with:
  echo    %__a_prg_dir__%\cmdchat.cmd [chatname]
  echo.
  echo please monitor the following file to view the active chat
  echo    %__a_chat__%
  echo.
  echo possible shortcuts in the Mainmenu:
  echo    type M to start monitoring with external Tailprogram the chatfile
  echo    type T to start monitoring with tail.exe the chatfile
  echo    type L to change the numbers of displayed lines
  echo    type B to change user to busy/break/lunch (busy-chat)
  echo    type C to change chat
  echo    type U to change username
  echo    type A to list all chats from today
  echo    type P to exPlore the Logfiles
  echo    type H to get this help
  echo    type E to exit cmdchat
  echo.
  echo ATTENTION:
  echo  please do not use special charakters, they may break the script!
  echo.
REM    echo Break cmdchat with [Strg]+[C] or [Ctrl]+[C] at every time
REM    echo.
  set __a_chat_text__=Mainmenu Help
  pause  
  goto loop
 
:end
  call :Time_German
  echo %__a_time__% %__a_user__%: ### User (%username%) EXIT the chat from %COMPUTERNAME% ### >> %__a_chat__%
  if not "%__a_chat_name__%"=="mainchat"  echo %__a_time__% %__a_user__%: ### User (%username%) EXIT the chat (%__a_chat_name__%) from %COMPUTERNAME% ### >> %__a_chat__%  >> %__a_mainchat__%
 goto quit

:: Subroutines
 
 
:GetIP
:: IP for primary adapter
  setlocal
  for /f "delims=: tokens=1-2" %%c in ('ipconfig /all ^| find "dress" ^| find "IP"') do set __a_getip__=%%d
  endlocal & set __a_getip__=%__a_getip__:~1%
  goto :EOF
 
 
:display_last_lines
:: tail the last x lines from chat
 
  if not exist %__a_tail_dir__%\tail.exe (
    echo please install %__a_tail_dir__%\tail.exe
    echo.
    type %__a_chat__%
  ) ELSE (
  %__a_tail_dir__%\tail.exe -n %__a_last_lines__% %__a_chat__%
  )
  goto :EOF
 
:Date_German
    FOR /F " usebackq tokens=1,2,3,4,* delims=." %%a IN (`echo %date%`) DO (
        set __a_Day__=%%a
        set __a_Month__=%%b
        set __a_Year__=%%c
    )
  goto :EOF
 
:Time_German
  setlocal
    FOR /F " usebackq tokens=1,2,3,4,* delims=:, " %%a IN (`echo %time%`) DO (
        set __a_Hour__=%%a
        set __a_Min__=%%b
        set __a_Sec__=%%c
        set __a_Hun=%%d
    )
    if %__a_Hour__% LEQ 9 set __a_Hour__=0%__a_Hour__%
    endlocal & set __a_time__=%__a_Hour__%:%__a_Min__%:%__a_Sec__%
  goto :EOF
 
:purge_input_os
 
  set "__a_str__=%__a_str__:^^=_%"
  set "__a_str__=%__a_str__:^%=_%"
  set "__a_str__=%__a_str__:^==_%"
  set "__a_str__=%__a_str__:^*=_%"
 
  set "__a_str__=%__a_str__:&=_%"
  set "__a_str__=%__a_str__:æ=_%"
  set "__a_str__=%__a_str__:ø=_%"
  set "__a_str__=%__a_str__:<=_%"
  set "__a_str__=%__a_str__:>=_%"
  set "__a_str__=%!!|%"
  set "__a_str__=%__a_str__:^=_%"
  set "__a_str__=%__a_str__:"=_%"
  set "__a_str__=%__a_str__:ï=_%"   
  set "__a_str__=%__a_str__:`=_%"
 
  set "__a_str__=%__a_str__:?=_%"
  set "__a_str__=%__a_str__:!=_%"
  set "__a_str__=%__a_str__:§=_%"
  set "__a_str__=%__a_str__:$=_%"
  set "__a_str__=%__a_str__:/=_%"
  set "__a_str__=%__a_str__:\=_%"
  set "__a_str__=%__a_str__:(=_%"
  set "__a_str__=%__a_str__:)=_%"
 
  set "__a_str__=%__a_str__:{=_%"
  set "__a_str__=%__a_str__:}=_%"
  set "__a_str__=%__a_str__:[=_%"
  set "__a_str__=%__a_str__:]=_%"
  set "__a_str__=%__a_str__:`=_%"
  set "__a_str__=%__a_str__:'=_%"
  set "__a_str__=%__a_str__:#=_%"
 
  call :purge_input_umlaut
 
  goto :EOF
 
:purge_input_text
 
  set "__a_str__=%__a_str__:&= !AND! %"
  set "__a_str__=%__a_str__:æ= !My! %"
  set "__a_str__=%__a_str__:ø= !DEGREE! %"
  set "__a_str__=%__a_str__:<= !LESS! %"
  set "__a_str__=%__a_str__:>= !GREATER! %"
  set "__a_str__=%!!|!!!! %"
  set "__a_str__=%__a_str__:^= !CTRL! %"
  set "__a_str__=%__a_str__:"=`%"
  set "__a_str__=%__a_str__:ï=`%"   
  set "__a_str__=%__a_str__:ý= !EXPONENT-2! %"
  set "__a_str__=%__a_str__:ü= !EXPONENT-3! %"
  call :purge_input_umlaut
 
  goto :EOF
 
:purge_input_umlaut
 
  set "__a_str__=%__a_str__:„=ae%"
  set "__a_str__=%__a_str__:”=oe%"
  set "__a_str__=%__a_str__:=ue%"
  set "__a_str__=%__a_str__:Ž=Ae%"
  set "__a_str__=%__a_str__:™=Oe%"
  set "__a_str__=%__a_str__:š=Ue%"
  set "__a_str__=%__a_str__:á=ss%"
  set "__a_str__=%__a_str__:ý=_2%"
  set "__a_str__=%__a_str__:ü=_3%"
 
REM   purge doubles
  set "__a_str__=%__a_str__:     = %"
  set "__a_str__=%__a_str__:    = %"
  set "__a_str__=%__a_str__:   = %"
  set "__a_str__=%__a_str__:  = %"
  set "__a_str__=%__a_str__:#####=#%"
  set "__a_str__=%__a_str__:####=#%"
  set "__a_str__=%__a_str__:###=#%"
  set "__a_str__=%__a_str__:##=#%"
  set "__a_str__=%__a_str__:##=#%"
  set "__a_str__=%__a_str__:_____=_%"
  set "__a_str__=%__a_str__:____=_%"
  set "__a_str__=%__a_str__:___=_%"
  set "__a_str__=%__a_str__:__=_%"
  set "__a_str__=%__a_str__:__=_%"
 
REM pause
 
  goto :EOF
 
:purge_user
 
  set __a_str__=%__a_str__%                    # len gt than 8 charakter
  set "__a_str__=%__a_str__:~0,8%"
 
  goto :EOF
 
:write_textblock
 
  set __a_chat_text__=### write a block of text ###
  set __a_text_block_file__=%tmp%\cmdchat_textblock.txt
 
  call :Time_German
 
  echo. > %__a_text_block_file__%
 
  rem EDIT textblock
 
  if "%__b_text__%" == "w" set __b_text__=W
 
  if not "%__b_text__%" == "W" goto write_textblock_go
 
:write_textblock_ask  
    cls
    echo ### CMDCHAT (%__a_vers__%) - write a block of text ###
    echo using as tempfile: %__a_text_block_file__%
    echo.
    echo You can use these shortcuts in the "new Text" directly
    echo.
    echo Which editor do you prefer:
    echo  WT = write directly in this window
    echo  WN = write with NOTEPAD
    echo  WE = write with EDIT
    echo  WD = write with your default Editor
    echo.
    echo Write Q to end/quit
    echo.
    set __b_text__=
    set /p __b_text__=Your choice:
      set __b_text__>nul 2>&1 || goto write_textblock_ask
    if "%__b_text__%"=="" goto write_textblock_ask
    if "%__b_text__%"=="w" goto write_textblock_ask
    if "%__b_text__%"=="W" goto write_textblock_ask
 
    if "%__b_text__%"=="t" set __b_text__=WT
    if "%__b_text__%"=="T" set __b_text__=WT
    if "%__b_text__%"=="d" set __b_text__=WD
    if "%__b_text__%"=="D" set __b_text__=WD
    if "%__b_text__%"=="n" set __b_text__=WN
    if "%__b_text__%"=="N" set __b_text__=WN
    if "%__b_text__%"=="e" set __b_text__=WE
    if "%__b_text__%"=="E" set __b_text__=WE
 
    if "%__b_text__%"=="q" set __b_text__=Q
    if "%__b_text__%"=="Q" (
      set __a_chat_text__=### write a block of text - aborted ###
 
      call :clear_vars
      goto :EOF
    )
 
:write_textblock_go
 
  rem WT - write text directly
  rem call :write_text_directly
  if "%__b_text__%" == "wt" call :write_text_directly & goto write_textblock_save
  if "%__b_text__%" == "WT" call :write_text_directly & goto write_textblock_save
 
  Rem WN - write with notepad
  if "%__b_text__%" == "wn" call :write_text_notepad & goto write_textblock_save
  if "%__b_text__%" == "WN" call :write_text_notepad & goto write_textblock_save
  rem call :write_notepad

  Rem WE - write with edit
  if "%__b_text__%" == "we" call :write_text_edit & goto write_textblock_save
  if "%__b_text__%" == "WE" call :write_text_edit & goto write_textblock_save

  Rem WD - write with default editor
  if "%__b_text__%" == "wd" call :write_text_default & goto write_textblock_save
  if "%__b_text__%" == "WD" call :write_text_default & goto write_textblock_save
 
  set __a_chat_text__=### write a block of text - no editor ###
 
  call :clear_vars
  goto :EOF
 
:write_textblock_save
 
  call :Time_German
  echo %__a_time__% %__a_user__%: --- wrote a textblock -------------------------------- >> %__a_chat__%
  type %__a_text_block_file__% >> %__a_chat__%
  echo %__a_time__% %__a_user__%: --- end of textblock --------------------------------- >> %__a_chat__%
  set __a_chat_text__=### wrote a textblock ###
 
  call :clear_vars
  goto :EOF
 
 
:write_text_directly
  set __a_chat_text__=### write a block of text directly ###
  cls
  echo ### CMDCHAT (%__a_vers__%) - write a block of text ###
  echo using as tempfile: %__a_text_block_file__%
  echo.
  echo ATTENTION:
  echo   you write in DOS-Mode!
  echo   spezial characters are display differnt in Windows!
  echo.
  echo type [Strg]+[Z] or [Ctrl]+[Z] or press [F6] to end
  echo.
  copy con %__a_text_block_file__%
  echo. >> %__a_text_block_file__%
  goto :EOF
 
:write_text_notepad
  set __a_chat_text__=### write a block of text with notepad ###
  cls
  echo ### CMDCHAT (%__a_vers__%) - write a block of text with notepad ###
  echo using as tempfile: %__a_text_block_file__%
  echo.
  echo ATTENTION:
  echo   you write in Windows-Mode!
  echo   spezial characters are display differnt in DOS!
  echo.
  echo save the text and close the NOTEPAD to go on
  echo.
  start /wait notepad.exe %__a_text_block_file__%
  goto :EOF
 
:edit_chatroom_notepad
  set __a_chat_text__=### edit the chatroom with notepad ###
  cls
  echo ### CMDCHAT (%__a_vers__%) - write a block of text with notepad ###
  echo using chatroom: %__a_chat__%
  echo.
  echo ATTENTION:
  echo   you write in Windows-Mode!
  echo   spezial characters are display differnt in DOS!
  echo.
  echo save the text and close the NOTEPAD to go on
  echo.
  start /wait notepad.exe %__a_chat__%
  goto :EOF
 
:edit_mainchat_notepad
  set __a_chat_text__=### edit the chatroom with notepad ###
  cls
  echo ### CMDCHAT (%__a_vers__%) - write a block of text with notepad ###
  echo using chatroom: %__a_mainchat__%
  echo.
  echo ATTENTION:
  echo   you write in Windows-Mode!
  echo   spezial characters are display differnt in DOS!
  echo.
  echo save the text and close the NOTEPAD to go on
  echo.
  start /wait notepad.exe %__a_mainchat__%
  goto :EOF
 
:write_text_edit
  set __a_chat_text__=### write a block of text with edit ###
  cls
  echo ### CMDCHAT (%__a_vers__%) - write a block of text with edit ###
  echo using as tempfile: %__a_text_block_file__%
  echo.
  echo ATTENTION:
  echo   you write in DOS-Mode!
  echo   spezial characters are display differnt in Windows!
  echo.
  echo save the text and close the EDIT to go on
  start /wait edit.com %__a_text_block_file__%
  goto :EOF
 
:write_text_default
  set __a_chat_text__=### write a block of text with default editor ###
  cls
  echo ### CMDCHAT (%__a_vers__%) - write a block of text with default editor ###
  echo using as tempfile: %__a_text_block_file__%
  echo.
  echo ATTENTION:
  echo   spezial characters are display differnt in Windows or DOS!
  echo.
  echo save the text and close your editor
  start %__a_text_block_file__%
  echo and then press in this window any key to go on
  pause > nul
  goto :EOF
 
:clear_vars
    set __a_str__=
    set __b_text__=
    set __a_text__=
    goto :EOF
 
:clear_all_defined_vars
  set ERRORLEVEL=
  set __a_chat__=
  set __a_chat_dir__=
  set __a_chat_name__=
  set __b_chat_name__=
  set __a_chat_text__=
  set __a_extension__=
  set __a_getip__=
  set __a_last_lines__=
  set __b_last_lines__=
  set __a_prefix__=
  set __a_prg_dir__=
  set __a_quest__=
  set __a_str__=
  set __a_tail__=
  set __a_tail_dir__=
  set __a_tail_prg__=
  set __a_text__=
  set __b_text__=
  set __a_text_block_file__=
  set __a_time__=
  set __a_user__=
  set __b_user__=
  set __a_vers__=
  set __a_version__=
  set __a_Day__=
  set __a_Hour__=
  set __a_Min__=
  set __a_Month__=
  set __a_Sec__=
  set __a_Year__=
  goto :EOF
 
rem ########## EOF ###########
 
:quit
  echo closing the window now
  pause
  exit 0
dos/cmdchat.txt · Zuletzt geändert: 2013/07/02 09:34 von Admin