-2

既成のバッチチャットを使っていて、自分なりに改良したい。

チャットの誰かが何かを言うと、次のように入力されます。 [John]: Hello World

私がやりたいことは[John]、プログラムの残りの部分とは別の色になることです。私はそれを機能させることはできません。誰かがこれを回避するのを手伝ってくれるといいのですが.

編集:call:コマンドはこれでは機能しません。colormsg や ctext などのさまざまなバッチを試しました。それらのどれも機能しません。問題は にあると思います>> log.dat

コードは次のとおりです。

@echo off
rem: Matthew Merchant ScriptingMadness.blogspot.com
rem ###### TITLE SCREEN ############
title Batch Chat Room
echo.
echo WELCOME TO THE CHAT!
echo:
echo:
echo Commands:
echo just hit ENTER to update screen.
echo.
set /p username=What is your name?
echo %username% has joined. >> log.dat
cls
goto CHATLOOP
REM ############################




REM ########## CHAT LOOP ##########
set lastmessage=""

:CHATLOOP
cls
type log.dat
echo.
echo.
set /p message=Say:

rem set message checker value
set thismessage="%message%"


rem check for exit
if %thismessage% == "EXIT" echo %username% has left the chat room. >> log.dat
if %thismessage% == "EXIT" exit
rem -----------------

rem check for clear
if %thismessage% == "CLS" echo %username% has cleared the chat log. > log.dat
if %thismessage% == "CLS" set message=Empty
if %thismessage% == "CLS" set lastmessage="Empty"
if %thismessage% == "CLS" goto CHATLOOP
rem ------------------

rem check for same message as last time
if %thismessage% == %lastmessage% goto CHATLOOP

rem if all checks out, go ahead and post this message
echo [%username%]: %message% >> log.txt

rem save value for next test
set lastmessage="%message%"

goto CHATLOOP
REM ################################

それでも意味が分からない場合。上記を参照してください:私%username%は別の色が欲しい%message%

4

1 に答える 1

0

できません。これは、vb.net、c# の前の私の最初のプログラミング言語でした。これをコーディングするのに 2 ~ 3 年を費やしましたが、色の値が背景またはテキストの色を設定することに気付きましたが、どのテキストを定義するかcolor コマンドを実行することは - 不可能です - Microsoft が提供するコマンドの一部ではないため、特定のテキスト行の色を定義することに集中しない管理ツールであることを思い出してください...

于 2013-03-11T00:11:30.370 に答える