GLOBAL DLL_Kernel32 AS INTEGER : DLL_Kernel32 = 1 : LOAD DLL "Kernel32.dll",DLL_Kernel32 GLOBAL ConsoleStdOut AS INTEGER Set Window On Console_Start() Console_Title("DarkBasic Console Test") Console_ForeColor("White",1) Console_WriteLine("Welcome to the Windows Console") Console_WriteLine("") Console_WriteLine("This is Useful for Displaying Debug Errors, Or information you do not want displaying Direct on the DarkBasic Window, Or when Testing Sections of your Code...") Console_WriteLine("") Do Loop ` -------------------------------------------------------------------------------------------------------------------- FUNCTION Console_Start() : ` Opens a console window, Returns 0 if fail Result = CALL DLL(DLL_Kernel32,"AllocConsole") ConsoleStdOut = CALL DLL(DLL_Kernel32,"GetStdHandle",-11) ENDFUNCTION Result FUNCTION Console_Stop() : ` Closes the Console Window, Returns 0 if fail Result = CALL DLL(DLL_Kernel32,"FreeConsole") ENDFUNCTION RESULT FUNCTION Console_WriteLine(Text$) : ` Writes the Text to a new line, returns 0 if fail Result = CALL DLL(DLL_Kernel32,"WriteConsoleA",ConsoleStdOut,Text$+CHR$(10),LEN(Text$+CHR$(10)),0,0) ENDFUNCTION RESULT FUNCTION Console_Write(Text$) : ` Writes text to the console window, Returns 0 if fail Result = CALL DLL(DLL_Kernel32,"WriteConsoleA",ConsoleStdOut,Text$,LEN(Text$),0,0) ENDFUNCTION Result FUNCTION Console_ForeColor(Color$,Bright) : ` Sets the Text Color, Returns 0 if fail Color$ = UPPER$(Color$) SELECT Color$ CASE "BLACK" : Col = 00 : ENDCASE CASE "BLUE" : Col = 01 : ENDCASE CASE "GREEN" : Col = 02 : ENDCASE CASE "RED" : Col = 04 : ENDCASE CASE "MAGENTA" : Col = 01 || 04 : ENDCASE CASE "CYAN" : Col = 02 || 01 : ENDCASE CASE "YELLOW" : Col = 04 || 02 : ENDCASE CASE "WHITE" : Col = 04 || 02 || 01 : ENDCASE ENDSELECT IF Bright = 1 THEN Col = Col || 010 Result = CALL DLL(DLL_Kernel32,"SetConsoleTextAttribute",ConsoleStdOut,Col) ENDFUNCTION Result FUNCTION Console_Title(Title$) : ` Sets the Windows Title Text, returns 0 if fail Result = CALL DLL(DLL_Kernel32,"SetConsoleTitleA",Title$) ENDFUNCTION Result ` -------------------------------------------------------------------------------------------------------------------- |