i stumbled into a problem. :(

A place where newbies can post without (much) fear of reprisal. All mission posts should still go in the applicable forum.
Forum rules
Older HTS users: Be nice to the new people.

NEW USERS: This is NOT the place to post about missions! Refer to "Missions" category.

i stumbled into a problem. :(

Post by skythir_edge on Sat Sep 08, 2012 10:12 pm
([msg=69265]see i stumbled into a problem. :([/msg])

I am in the process of programming an batch rpg game. I need to find out how to print different color txt at the same time. Is there an easy way of doing this, if you even can?
skythir_edge
New User
New User
 
Posts: 4
Joined: Sat Sep 08, 2012 2:47 am
Blog: View Blog (0)


Re: i stumbled into a problem. :(

Post by LoGiCaL__ on Sun Sep 09, 2012 8:05 am
([msg=69281]see Re: i stumbled into a problem. :([/msg])

Check out this link:

http://stackoverflow.com/questions/7923948/batch-color-per-line

Edit:

Looks like the colors are off, here's a reference for the Color command:

http://www.computerhope.com/color.htm
User avatar
LoGiCaL__
Addict
Addict
 
Posts: 1063
Joined: Sun May 30, 2010 12:33 pm
Blog: View Blog (0)


Re: i stumbled into a problem. :(

Post by WallShadow on Sun Sep 09, 2012 11:12 am
([msg=69282]see Re: i stumbled into a problem. :([/msg])

LoGiCaL__ wrote:Check out this link:

http://stackoverflow.com/questions/7923948/batch-color-per-line

Edit:

Looks like the colors are off, here's a reference for the Color command:

http://www.computerhope.com/color.htm




dafuq are you saying logical? The first link points to a great resource, +1, I've actually been wanting something like this for a while. The color command changes THE WHOLE DOS PROMPT to your desired color (ie, saying 'color 56' will change the entire command window and all the text in it to an ugly mix of purple and yellow). The only good thing about the color command is that it uses the same color codes as the findstr command that is utilized in the utility you pointed to at first.
User avatar
WallShadow
Contributor
Contributor
 
Posts: 614
Joined: Tue Mar 06, 2012 9:37 pm
Blog: View Blog (0)


Re: i stumbled into a problem. :(

Post by LoGiCaL__ on Sun Sep 09, 2012 3:45 pm
([msg=69288]see Re: i stumbled into a problem. :([/msg])

WallShadow wrote:
LoGiCaL__ wrote:Check out this link:

http://stackoverflow.com/questions/7923948/batch-color-per-line

Edit:

Looks like the colors are off, here's a reference for the Color command:

http://www.computerhope.com/color.htm




dafuq are you saying logical? The first link points to a great resource, +1, I've actually been wanting something like this for a while. The color command changes THE WHOLE DOS PROMPT to your desired color (ie, saying 'color 56' will change the entire command window and all the text in it to an ugly mix of purple and yellow). The only good thing about the color command is that it uses the same color codes as the findstr command that is utilized in the utility you pointed to at first.


The first resource is good but the colors are wrong. Hence, me putting up the 2nd link. dafuq you talking about?
User avatar
LoGiCaL__
Addict
Addict
 
Posts: 1063
Joined: Sun May 30, 2010 12:33 pm
Blog: View Blog (0)


Re: i stumbled into a problem. :(

Post by WallShadow on Sun Sep 09, 2012 3:59 pm
([msg=69291]see Re: i stumbled into a problem. :([/msg])

If you read closely, it was done on purposes like that. It's one of those illusions/mind-tricks where you read the word 'red' but you say blue because the word is written in blue and not red.

If you want a corrected one, here:

Code: Select all
@echo off
SETLOCAL EnableDelayedExpansion
for /F "tokens=1,2 delims=#" %%a in ('"prompt #$H#$E# & echo on & for %%b in (1) do rem"') do (
  set "DEL=%%a"
)
echo COLORS!!!

REM 0 is normally black but entering a color with its own background such as '00' or 'AA' or 'FF' will just reset the color to the default because otherwise, you wouldn't be able to read anything

call :ColorText 00 "default"
call :ColorText 01 "blue"
call :ColorText 02 "green"
call :ColorText 03 "aqua"
call :ColorText 04 "red"
call :ColorText 05 "purple"
call :ColorText 06 "yellow"
call :ColorText 07 "white"
ECHO(
call :ColorText 08 "gray"
call :ColorText 09 "lightblue"
call :ColorText 0A "lightgreen"
call :ColorText 0B "lightaqua"
call :ColorText 0C "lightred"
call :ColorText 0D "lightpurple"
call :ColorText 0E "lightyellow"
call :ColorText 0F "brightwhite"
ECHO(

call :ColorText F0 "black on brightwhite"
ECHO(
call :ColorText E1 "blue on lightyellow"
ECHO(
call :ColorText D2 "green on lightpurple"
ECHO(
call :ColorText C3 "aqua on lightred"
ECHO(
call :ColorText B4 "red on lightaqua"
ECHO(
call :ColorText A5 "purple on lightgreen"
ECHO(
call :ColorText 96 "yellow on lightblue"
ECHO(
call :ColorText 87 "white on gray"
ECHO(
ECHO(
ECHO(
call :ColorText 78 "gray on white"
ECHO(
call :ColorText 69 "lightblue on yellow"
ECHO(
call :ColorText 5A "lightgreen on purple"
ECHO(
call :ColorText 4B "lightaqua on red"
ECHO(
call :ColorText 3C "lightred on aqua"
ECHO(
call :ColorText 2D "lightpurple on green"
ECHO(
call :ColorText 1E "lightyellow on blue"
ECHO(
call :ColorText 0F "brightwhite on black"
ECHO(
goto :eof

:ColorText
echo off
<nul set /p ".=%DEL%" > "%~2"
findstr /v /a:%1 /R "^$" "%~2" nul
del "%~2" > nul 2>&1
goto :eof




User avatar
WallShadow
Contributor
Contributor
 
Posts: 614
Joined: Tue Mar 06, 2012 9:37 pm
Blog: View Blog (0)


Re: i stumbled into a problem. :(

Post by LoGiCaL__ on Sun Sep 09, 2012 4:31 pm
([msg=69292]see Re: i stumbled into a problem. :([/msg])

I don't know how else to say this.

LoGiCaL__ wrote:Edit:

Looks like the colors are off, here's a reference for the Color command:

http://www.computerhope.com/color.htm


I don't think the OP would have got the color scheme from the link I posted.
User avatar
LoGiCaL__
Addict
Addict
 
Posts: 1063
Joined: Sun May 30, 2010 12:33 pm
Blog: View Blog (0)


Re: i stumbled into a problem. :(

Post by WallShadow on Sun Sep 09, 2012 4:40 pm
([msg=69293]see Re: i stumbled into a problem. :([/msg])

a quick google search, and stumbled onto this: http://www.codeproject.com/Articles/170 ... atch-Files

I can't seem to get the source to work properly after compiling, but the executable they provided works like a charm. It works by a style of formatted strings, typing "cecho.exe this is {01}blue{#}" will render the word blue in the 01 color which is blue on a black background. whats also cool is that if you type "cecho.exe {01}" it will begin the formatting, but it will never end it, thus anything you type, even after cecho.exe has exited will still be in blue.
User avatar
WallShadow
Contributor
Contributor
 
Posts: 614
Joined: Tue Mar 06, 2012 9:37 pm
Blog: View Blog (0)


Re: i stumbled into a problem. :(

Post by LoGiCaL__ on Sun Sep 09, 2012 5:47 pm
([msg=69295]see Re: i stumbled into a problem. :([/msg])

Is a 3rd party program involved? I don't think (correct me if I'm wrong) that cecho is a natural command.
User avatar
LoGiCaL__
Addict
Addict
 
Posts: 1063
Joined: Sun May 30, 2010 12:33 pm
Blog: View Blog (0)


Re: i stumbled into a problem. :(

Post by WallShadow on Sun Sep 09, 2012 7:39 pm
([msg=69302]see Re: i stumbled into a problem. :([/msg])

cecho is not a natural program, but the link i gave points to a minor code project which provides source code and executables of a program called cecho which is meant to extend batch functionality with colored text.
User avatar
WallShadow
Contributor
Contributor
 
Posts: 614
Joined: Tue Mar 06, 2012 9:37 pm
Blog: View Blog (0)



Return to NZone

Who is online

Users browsing this forum: No registered users and 0 guests