• Advertisement

Archived

This topic is now archived and is closed to further replies.

Color Text...

This topic is 6063 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey, I was wondering if I am programming in DOS and C++, do I have to enter a certain video mode in order to get colored text. I wouldn''t think you would have to, but I''m probably wrong. If anyone knows where I can learn about colored text in DOS, please share Thanks

Share this post


Link to post
Share on other sites
Advertisement
I also would like to know this...

~~~~
sjunkim - P0et
Liquid Ice Studios
members.home.net/liquidicestudios/

Share this post


Link to post
Share on other sites
As I end up pointing out at least once every week, DOS != Win32 Console.

So, if you''re talking about a Win32 Console app, you''ll use the Console functions such as SetConsoleTextAttribute. Consult MSDN for more info on those.

Otherwise, you''re legitimately talking about DOS, in which case you''ll have to mess with some interrupts to make the BIOS do this for you.

Share this post


Link to post
Share on other sites
If you are using dos, you can use ANSI colour codes

make sure your config.sys includes ''set device=ansi.sys'' (you may need to include a path -ie, for windows OS it''s usually ''c:\windows\command\ansi.sys'' )

then you can use ansi escape sequences ESC[32c for instance. (where ESC is character 27 i think (from memory - been a while - look for the codes somewhere like oulu))

This will also work in windows console mode btw. And it lets you position text on the screen as well as colouring it.

- Wyzfen

Share this post


Link to post
Share on other sites
You said you were coding C++ in DOS. Hmmm... I think there was setcolor and setbkcolor-functions which changed the colors. Like setcolor(1); --> sets blue etc... setbkcolor(1); --> sets background to blue.
Hope this helps!

Share this post


Link to post
Share on other sites
Sadly, those functions are compiler-specific (and obviously non-standard, though that''s not an issue here). To my knowledge, they''re only available with Turbo C++, and you''d include conio.h. And you might have to use the output functions in conio.h to use the color, such as cprintf and cputs--I don''t quite remember.

Share this post


Link to post
Share on other sites
If you use the ANSI escape sequences you can use any output functions you like... as long as it eventually goes to standard out.

If you are using WindowsME, though, you can no longer load older DOS drivers. As a matter of fact, you can''t even modify the blank autoexec.bat or config.sys that resides in the root directory.

Share this post


Link to post
Share on other sites
I havent tried this yet, so it might work using the system() command in a console. The system() comman lets you use old DOS commands in the console applications. Example: system("c:\dir")
this prints a directory listing. I thought there was a command in dos that let you set the colors of your text on the fly this might be the way to implement it.

"There is humor in everything depending on which prespective you look from."

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
I havent tried this yet, so it might work using the system() command in a console. The system() comman lets you use old DOS commands in the console applications. Example: system("dir")
this prints a directory listing. I thought there was a command in dos that let you set the colors of your text on the fly this might be the way to implement it.

"There is humor in everything depending on which prespective you look from."

Share this post


Link to post
Share on other sites

  • Advertisement