changing the text color in DOS possible?

BlitzMax Forums/BlitzMax Programming/changing the text color in DOS possible?

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Here you go, pretty simple

Edit: And oh btw its probably not the best idea to post the same topic multiple times (you've posted it in the beginners area as well)

' Simple console color example
' Written by Tim Leonard (Aka. Helios)

' Setup compiler
SuperStrict

' Import win32 functions
Extern "Win32"
	Function SetConsoleTextAttribute:Int(hConsoleOutput:Int Ptr,wAttributes:Int)
	Function GetStdHandle:Int Ptr(nStdHandle:Int)
End Extern

' A few usefull constants
Const STD_OUTPUT_HANDLE:Int = -11;
Const COLOR_BLACK:Int	= $0000
Const COLOR_BLUE:Int 	= $0001
Const COLOR_GREEN:Int 	= $0002 
Const COLOR_CYAN:Int 	= $0003
Const COLOR_RED:Int	= $0004
Const COLOR_MAGENTA:Int= $0005
Const COLOR_YELLOW:Int = $0006
Const COLOR_GREY:Int 	= $0007
Const COLOR_WHITE:Int 	= $0008

' Print out some junk to test the colors
Print "Hello world!"
SetConsoleColor(COLOR_RED|COLOR_WHITE) ; Print "Hello world!"
SetConsoleColor(COLOR_GREEN,True) 	   ; Print "Hello world!"

' Wait till somone presses a key
Print "Done, press any key to exit"
While Not AppTerminate()
Wend

' Sets the color of the console
Function SetConsoleColor(Color:Int,Background:Int = False)
	If Background = True Then Color:*$0010
	SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),Color)	
End Function