Author Topic: Graphical console output (PRINT console)  (Read 1935 times)

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10651
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
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