'===========================================================================
' Subject: SCREEN DRAWING ROUTINES            Date: 10-09-95 (00:00)       
'  Author: Kenneth W. Melvin                  Code: QB, QBasic, VB         
'  Origin: kwmelvin@nr.infi.net             Packet: TEXT.ABC
'===========================================================================
'Filename:  DEMOSCRN.BAS
'Date:      10-9-1995 kwm
'For:       QBasic, QuickBASIC, VBDOS
'Purpose:   Demonstration of drawing screens and passing parameters
'            to SUBprocedures. An example of structured programming.

DECLARE SUB Shadows (UpRow%, LeftCol%, BotRow%, RtCol%)
DECLARE SUB DrawBorder (UpRow%, LeftCol%, BotRow%, RtCol%)
DECLARE SUB Background ()
DECLARE SUB ClearScrn (UpRow%, LeftCol%, BotRow%, RtCol%)

DEFINT A-Z                              'defines variables of type integer
CLS                                     'clear the screen

UpRow = 4                               'change any of these coordinates
LeftCol = 15                            'at this one location, and the
BotRow = 15                             'size of the window, the border,
RtCol = 65                              'and shadows change automatically.

Background                                      'draws a background      
CALL ClearScrn(UpRow, LeftCol, BotRow, RtCol)   'clears a blank area
CALL DrawBorder(UpRow, LeftCol, BotRow, RtCol)  'draws a border in blank area
CALL Shadows(UpRow, LeftCol, BotRow, RtCol)     'draws shadows under window

COLOR 0, 3                              'black FG, cyan BG
LOCATE UpRow + 3, LeftCol + 16          'position text in window
PRINT "This is DEMOSCRN.BAS"            'message
COLOR 0, 7                              'white FG, black BG

END

SUB Background
    COLOR 0, 7
    FOR i = 1 TO 80
        FOR j = 1 TO 25
            PRINT CHR$(176);
        NEXT
    NEXT
END SUB

SUB ClearScrn (UpRow, LeftCol, BotRow, RtCol)
    COLOR 0, 7
    LOCATE UpRow, LeftCol
    FOR i = UpRow TO BotRow
        LOCATE i, LeftCol
        PRINT STRING$(RtCol - LeftCol + 1, CHR$(219))
    NEXT
END SUB

SUB DrawBorder (UpRow, LeftCol, BotRow, RtCol)
   
    COLOR 0, 3      'change border color by changing FG [COLOR FG, BG] (0-15)
                    'change box color by changing BG (0-7 only)
                    '0=black 1=blue 2=green 3=cyan 4=red 5=magenta 6=brown
                    '7=white 8=gray 9=hiBlue 10=hiGreen 11=hiCyan 12=hiRed
                    '13=hiMagenta 14=Yellow 15=hiWhite
   
    LOCATE UpRow, LeftCol
    PRINT CHR$(213) + STRING$(((RtCol - LeftCol) - 1), CHR$(205)) + CHR$(184)
   
    FOR i = (UpRow + 1) TO (BotRow - 1)
      LOCATE i, LeftCol
      PRINT CHR$(179) + STRING$(((RtCol - LeftCol) - 1), CHR$(32)) + CHR$(179)
    NEXT
   
    LOCATE BotRow, LeftCol
    PRINT CHR$(212) + STRING$(((RtCol - LeftCol) - 1), CHR$(205)) + CHR$(190)

END SUB

SUB Shadows (UpRow, LeftCol, BotRow, RtCol)
    COLOR 8, 0              'color of shadow
    'horizontal shadow at bottom
    LOCATE BotRow + 1, LeftCol + 2
    PRINT STRING$((RtCol - LeftCol), CHR$(178))
    'vertical shadow at right side
    FOR i = UpRow + 1 TO BotRow
        LOCATE i, RtCol + 1: PRINT CHR$(178)
    NEXT
END SUB

