echoes text in a specific color - help
Moderator: DosItHelp
-
- Posts: 7
- Joined: 10 Apr 2012 19:17
echoes text in a specific color - help
Hi! I'm new at the forum.
First I'd like to thanks, 'cause I already used many tips and examples of codes posted here!
Now, my question:
- I'm trying to use the echo function posted here, in order to echoes with colors. It works fine, but I need to have a screen with many rows (scroll) and when I use the echo function, the screen buffer is missed. It seens like the cmd window resizes each time it calls the echo and then turn back to the original size and some upper rows are missed.
Does anybody know how to solve that?
Thanks a lot!
First I'd like to thanks, 'cause I already used many tips and examples of codes posted here!
Now, my question:
- I'm trying to use the echo function posted here, in order to echoes with colors. It works fine, but I need to have a screen with many rows (scroll) and when I use the echo function, the screen buffer is missed. It seens like the cmd window resizes each time it calls the echo and then turn back to the original size and some upper rows are missed.
Does anybody know how to solve that?
Thanks a lot!
-
- Posts: 7
- Joined: 10 Apr 2012 19:17
Re: echoes text in a specific color - help
'
Well, I'm getting the famous for /f bug on XP, and did a dirty quick fix.
I see what u mean now, the screen buffer is being eaten and it seems to be caused by the COM file,
I know close to nothing about COM files, let's wait for an assembly wizard to pass by...
I'm interested in which OS you use, as you say it works perfectly with you, win7 ?
Well, I'm getting the famous for /f bug on XP, and did a dirty quick fix.
I see what u mean now, the screen buffer is being eaten and it seems to be caused by the COM file,
I know close to nothing about COM files, let's wait for an assembly wizard to pass by...
I'm interested in which OS you use, as you say it works perfectly with you, win7 ?
Code: Select all
@echo off &setlocal enableDelayedExpansion
for /l %%? in ( 1, 1, 50 ) do (
call :echo 0C. "Hello "
call :echo 0F "world"
)
pause
exit /b 0
:echo col txt -- echoes text in a specific color
:: -- col [in] - color code, append a DOT to omit line break, call 'color /?' for color codes
:: -- txt [in] - text output
:$created 20060101 :$changed 20080219 :$categories Echo,Color
:$source http://www.dostips.com
SETLOCAL
2>nul (
for /f "tokens=1,*" %%a in ("%*") do (
set col=%%a
set txt=%%~b
)
)
set cr=Y
if "%col:~-1%"=="." (
set cr=N
set col=%col:~0,-1%
)
call:getColorCode "%col%" col
set com=%temp%.\color%col%.com
if not exist "%com%" (
echo.N %COM%
echo.A 100
echo.MOV BL,%col%
echo.MOV BH,0
echo.MOV SI,0082
echo.MOV AL,[SI]
echo.MOV CX,1
echo.MOV AH,09
echo.INT 10
echo.MOV AH,3
echo.INT 10
echo.INC DL
echo.MOV AH,2
echo.INT 10
echo.INC SI
echo.MOV AL,[SI]
echo.CMP AL,0D
echo.JNZ 109
echo.RET
echo.
echo.r cx
echo.22
echo.w
echo.q
)|debug>NUL
"%com%" %txt%
rem del "%com%" /q
if "%cr%"=="Y" echo.
EXIT /b
:getColorCode col ret -- converts color text to color code
:: -- col [in] - color text BackgroundForeground, i.e.: BlueLYellow for 1E
:: -- ret [out] - return variable to return color code in
:$created 20060101 :$changed 20080219 :$categories Color,Echo
:$source http://www.dostips.com
SETLOCAL
set col=%~1
set col=%col:Gray=8%
set col=%col:LBlue=9%
set col=%col:LGreen=A%
set col=%col:LAqua=B%
set col=%col:LRed=C%
set col=%col:LPurple=D%
set col=%col:LYellow=E%
set col=%col:LWhite=F%
set col=%col:Black=0%
set col=%col:Blue=1%
set col=%col:Green=2%
set col=%col:Aqua=3%
set col=%col:Red=4%
set col=%col:Purple=5%
set col=%col:Yellow=6%
set col=%col:White=7%
ENDLOCAL & IF "%~2" NEQ "" (SET %~2=%col%) ELSE (echo.%col%)
-
- Posts: 7
- Joined: 10 Apr 2012 19:17
Re: echoes text in a specific color - help
I'm using Win7, but I'm experiencing the "buffer problem" even in win7 and XP.
The same problem occours using ColorMsg.com that u mentioned before.
It really seens something related with .com files.
Let's see if somebody else can help.
Thanks.
The same problem occours using ColorMsg.com that u mentioned before.
It really seens something related with .com files.
Let's see if somebody else can help.
Thanks.
Re: echoes text in a specific color - help
x64 ?
16-bit programs like .com not works on 64-bit OS
16-bit programs like .com not works on 64-bit OS
-
- Posts: 7
- Joined: 10 Apr 2012 19:17
Re: echoes text in a specific color - help
No. it's Win 32-bit.
-
- Posts: 7
- Joined: 10 Apr 2012 19:17
Re: echoes text in a specific color - help
After more tests I've realized that it keeps only the 50 last lines.
I don't know why just 50...
I don't know why just 50...