'BCX console demo, ported to Oxygenbasic
$ filename "ColonTest.exe"
'uses rtl32
'uses rtl64

#console
% TryAttachConsole
uses console

type CONSOLE_CURSOR_INFO  
    dword dwSize
    bool  bVisible 
end type 

extern lib "KERNEL32.DLL"
! SetConsoleCursorInfo(sys hConsoleOutput, CONSOLE_CURSOR_INFO *lpConsoleCursorInfo) as bool
end extern 

sub locate (int row,int col,optional int showCursor=1,int shape=12)
  CONSOLE_CURSOR_INFO cci
  SetPos(col-1,row-1)
  cci.bVisible = showCursor
  cci.dwSize   = shape
  SetConsoleCursorInfo(ConsOut, cci)
end sub

sub setcolor(int fg, bg)
  SetConsoleTextAttribute (ConsOut, fg+bg*16)
end sub

sub panel(int x1,int y1,int x2,int y2,int fg,int bg,int ASCode,int clearflg)
   COORD cursor
   sys written
   int attr = fg+bg*16
   int x,y
   for y=y1 to y2
     for x=x1 to x2
        cursor.X = x - 1
        cursor.Y = y - 1
        'if clearflg then clear existing text
        if clearflg then FillConsoleOutputCharacterA (ConsOut,ASCode,1,cursor.c, written)
        FillConsoleOutputAttribute(Consout,attr,1,cursor.c, written)
   next x
 next y
end sub

cls

-------------------------------------------------------------------------
' This is meant to show the use of colon separated compound statements
' -------------------------------------------------------------------------
                 ':cls:  does not work?
dim a:setcolor 7,0:cls :for a=1 to 23:print "This is line number "a:print cr:next:print "This is line number "a++:print "  Enter ...":call panel(5,10,20,20,15,1,32,0):locate 1,50,0:waitkey:call panel(5,10,20,20,15,4,32,1):locate 1,1,0:waitkey:cls
