OpenConsole()

Syntax

Result = OpenConsole([Title$ [, Mode]])
Description
Open a console window. This function must be called before any other function of this library. Only one console can be opened at the same time in a PureBasic program.

Parameters

Title$ (optional) The title for the new console window. On Windows, specifying a title allow the saving of custom console parameter, like font, color etc. It has no effect on other OS.
Mode (optional) The mode to use for console output. It can one of the following value:
  - #PB_UTF8: string will use UTF-8 format when printed to the console (default).
  - #PB_Ascii: string will use ASCII format when printed to the console.
  - #PB_Unicode: string will use UTF-16 format when printed to the console. Can be useful on Windows
                 when using string redirection, and the target program expect UTF-16 input. Has no effect
                 on Linux or OS X (will use UTF-8).

Return value

If Result is 0, it has failed and all further call to console functions must be disabled.

Remarks

The console can be closed using the CloseConsole() function.

With EnableGraphicalConsole() the console can be switched between text and graphics mode.

On Microsoft Windows, there are two different executable formats: Win32 and Console. If you want to create a standard console application, like 'dir', 'del' etc. you must compile the executable using the 'Console' format (Compiler Option menu in the PureBasic IDE). On Linux and OS X, there is no special Console format however setting the Compiler option to 'Console' will launch a terminal window automatically when you run your program from the IDE.

Example

  OpenConsole()
  PrintN("Waiting 5 secs before quit...")
  Delay(5000)

See Also

CloseConsole(), EnableGraphicalConsole()

Supported OS

All

<- Input() - Console Index - Print() ->