1.

Solve : Multiple Colours.?

Answer»

nope, just echo's it, if i type in ansi /? in cmd. it ays it does not recognise it, is it installed properly?Hi

Use the Windows Start then RUN and type in the "open" box CMD
Use the Windows Start then RUN and type in the "open" box COMMAND

You now have two DOS windows, "Old DOS" and "New DOS"
They look the same till you use them !!!

They both do exactly what you report - they do not recognise ansi

NOW TRY
ANSI.SYS /?
They both launch Notepad with a screen of garbage - you were not supposed to do that !!!

Ansi.sys is located somewhere on the Environmental variable PATH.
It should be found if it lives on the path, and if
a) The file extension is included, or
b) The extension is one of the defaults listed in PATHEXT
For me
PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH

You just SAID "if i type in ansi /? in cmd."
This suggests a second error, you used "cmd". I never knew till Dias pointed this out, but ANSI graphics etc do NOT work in a CMD (New DOS) shell, only in a COMMAND (Old DOS) Shell.

Finally, again as Dias has just explained, you need
1. Edit or create a config.nt file in "c:\windows\system32" folder.
2. Add the line: device=c:\windows\system32\ansi.sys

That will incorporate/INSTALL/whatever ansi.sys so that when a COMMAND shell delivers a character stream to the console, it will be intercepted/translated so that what eventually appears will include ansi graphic manipulations where required, and otherwise the words will look the same as normal. This only hapens with a COMMAND shell.
It is not available with CMD
you can have colours, or you can have delayedexpansion etc. etc., but not both.

Note, Ansi.sys is only INVOKED by the config.nt start up file.
The batch files never invoke ansi.sys - they only do whatever they do, and any console output may gain the benefit of Ansi.sys when it is running, but I doubt that the batch command has any way of telling whether or not it ANSI.sys is actually doing anything.

If the batch file should invoke ansi.sys it wont do any good - don't know if it does any harm.
Similarly batch can only abuse device=c:\windows\system32\ansi.sys
i.e. I will not try that - I know it wont help, and I fear it could harm - e.g. will it attempt to install (or whatever it is called) a driver at the wrong time and in the wrong place, and might this damage the existing drivers so that interrupts are no longer serviced and files are no longer written ?
I don't know what will go wrong. I only know that "Dragons Be Here"

Regards
Alan
Quote

I doubt that the batch command has any way of telling whether or not it ANSI.sys is actually doing anything.


Run these under COMMAND

Code: [Select]C:\>mem /c

Conventional Memory :

Name Size in Decimal Size in Hex
------------- --------------------- -------------
MSDOS 12368 ( 12.1K) 3050
KBD 3296 ( 3.2K) CE0
HIMEM 1248 ( 1.2K) 4E0
ANSI 4192 ( 4.1K) 1060<---ANSI.SYS is loaded---<
COMMAND 4160 ( 4.1K) 1040
DOSX 34720 ( 33.9K) 87A0
COMMAND 5312 ( 5.2K) 14C0
KB16 6096 ( 6.0K) 17D0
FREE 112 ( 0.1K) 70
FREE 583584 (569.9K) 8E7A0

Total FREE : 583696 (570.0K)

Upper Memory :

Name Size in Decimal Size in Hex
------------- --------------------- -------------
SYSTEM 221168 (216.0K) 35FF0
DOSX 128 ( 0.1K) 80
MSCDEXNT 464 ( 0.5K) 1D0
MOUSE 12528 ( 12.2K) 30F0
REDIR 2672 ( 2.6K) A70
FREE 1360 ( 1.3K) 550
FREE 6160 ( 6.0K) 1810
FREE 17504 ( 17.1K) 4460

Total FREE : 25024 ( 24.4K)

Total bytes available to programs (Conventional+Upper) : 608720 (594.5K)
Largest executable program size : 582192 (568.5K)
Largest available upper memory block : 17504 ( 17.1K)

1048576 bytes total contiguous extended memory
0 bytes available contiguous extended memory
941056 bytes available XMS memory
MS-DOS resident in High Memory Area

Code: [Select]@echo off
mem /c > mem.txt
find "ANSI" mem.txt >nul
if errorlevel 1 goto no
echo ansi is loaded
goto next
:no
echo ansi is not loaded
:next
I have now come to the conclusion that ANSI is in use.
All I need to know now is how to get multiple colours using ANSI in a batch file.Hi

Here is an old file that worked on Windows 95.

The last line used ANSI to modify the prompt to give colours that distinguished which drive the command shell was set to.

If you launch COMMAND.COM then rename this as *.bat and run it the prompt should change colour as you go through alternate "CD C:\" , "CD D:\" etc commands.

You should only need the last line - but I wont edit this myself because NOTEPAD does all sorts of strange things for me.

Regards
Alan.




[Saving space - attachment deleted by admin]Thanks for your help but I am looking for a straight answer, for instance to get echo red as red on one line type...blah and to get echo blue, blue on another line type.....

From your advice:
Code: [Select]prompt $p$G$E[s$E[1;5;7m$E[0$N$E[0m$E[Does nothing.
But thanks for your time so far.Quote from: Jacob
I am looking for a straight answer,

The straight answer is that you can't use ansi.sys to make coloured text in XP or Vista.

You can use 3rd party utils like ctext.exe

http://dennisbareis.com/freew32.htm



Thank you, i've been waiting for this answer for about a week, and finally it has come.
Well after unzipping it I had the desired effect in seconds, thanks for your help ALAN, and of course Dias.Quote from: Jacob on November 06, 2008, 01:22:04 PM
Thank you, i've been waiting for this answer for about a week

It is bad manners to complain that you have waited so long! You should be glad you got an answer at all!

Quote
and of course Dias.

And also little Dias who found you the free software!
YES, thanks, time of the month?
Oh, and you should see my game with these new colours.
If their health is below half it goes red but if it is above half then it is green.
<3
(video attached as a .zip)

[Saving space - attachment deleted by admin]You did this with ctext.exe ? I did not think you could have different colours on the same line? It looks very good! I was only teasing you before.

Yes I did, and thank you for your help, you have helped me on practically everything I have posted here.
To do two colours on the same line just do not use {\n}
Don't worry, and thanks for your amazing help once again, Dias saves the day.

Here is how you do more than 1 colour per line.
Code: [Select]@echo off
ctext.exe "{0A}0A - Bright Green{0B}0B - Bright Cyan{\n}"
pause >nul

Just keep adding {colour}'s


Discussion

No Comment Found