GLBasic forum

Codesnippets => 2D-snippets => Topic started by: Kitty Hello on 2009-Oct-27

Title: Graphical console output (PRINT console)
Post by: Kitty Hello on 2009-Oct-27
Hi, this is a very basic but compact console output with a clear function:
Code (glbasic) Select


FUNCTION ConsolePrt: text$, bClear%=FALSE
LOCAL fx%, fy%, scx%, scy%
GETFONTSIZE fx%, fy%
GETSCREENSIZE scx%, scy%

STATIC buffer$[]
IF bClear% THEN REDIM buffer$[0]
DIMPUSH buffer$[], text$
IF (LEN(buffer$[])-1) * fy >= scy
DIMDEL buffer$[], 0
ENDIF

LOCAL y% = 8
FOREACH s$ IN buffer$[]
PRINT s$, 8, y%
INC y%, fy%
NEXT
SHOWSCREEN
ENDFUNCTION

FUNCTION ConsoleClr:
ConsolePrt("", TRUE)
ENDFUNCTION