Name
AllocConsoleColor -- allocate console color (V10.0)
Synopsis
col = AllocConsoleColor(color)
Platforms
Linux, macOS, Windows

Function
This function allocates the color specified by color for the current console and returns it. You can then make it the active color by passing it to functions like SetConsoleColor(). Color allocation is necessary because by default only a few predefined ANSI colors like #BLACK, #WHITE, #RED, etc. are available. If you want to use custom colors, you need to allocate them first.

When you're done with a color allocated by this function, call FreeConsoleColor() to a free the color. This is important to make sure that you don't run out of colors.

You must enable advanced console mode using EnableAdvancedConsole() before you can use this function. See EnableAdvancedConsole for details.

Inputs
color
color to allocate; this must be passed as an RGB color
Results
col
allocated color
Example
EnableAdvancedConsole()
SetConsoleColor(1, AllocConsoleColor($FFA500))
ConsolePrint("Hello World")
RefreshConsole()
The code above prints the string "Hello World" in orange. Note that under normal circumstances you should free the console color when you're done with it. This part has been left out for readability reasons.

Show TOC