Go to:  Davar site entry | Site contents | Site index | Personal Computer | PowerBASIC | Text bottom

PRNTCLR  PowerBASIC  Routine

         

PRNTCLR routine displays text starting at the current screen position. Text being displayed may contain color switching codes to highlight its portions.

Debugging program provides an example of the PRNTCLR routine usage that is intentionally tailored to resemble the SETCOLOR 4DOS batch script, color codes of which have been implemented by PRNTCLR routine.




 PRNTCLR  Source  Program                       Debugging program                   Debugging logout

      ' PRNTCLR(0.0)  Print Colored Text to Screen           09/25/1992-07/08/2005
      ' --------------------------------------------------------------------------
      ' Copyright (C) 1992-2005 by Vladimir Veytsel                  www.davar.net

      ' Type ---------------------------------------------------------------------

      '    Routine

      ' Declaration --------------------------------------------------------------

      '    DECLARE SUB PRNTCLR(Text$)

      ' Parameter ----------------------------------------------------------------

      '    Text$  - Text to be printed starting at current screen position that may
      '             contain color switching codes in the form of "%<code>%".

      '             Color           Code  Sample Usage
      '             --------------  ----  -------------
      '             Bright Red       R    Error message
      '             Bright Green     G    Title, info or disk name/letter
      '             Bright Yellow    Y    Command name or text accent
      '             Bright Blue      B    Status message
      '             Bright Magenta   M    Error message highlight
      '             Bright Cyan      C    Key, status msg h/l or complex message
      '             Bright White     W    Request or text highlight
      '             Gray             D    DOS regular text

      '             Corresponding PowerBASIC color switching operators:

      '             COLOR 12,0  ' Bright Red     on Black
      '             COLOR 10,0  ' Bright Green   on Black
      '             COLOR 14,0  ' Bright Yellow  on Black
      '             COLOR  9,0  ' Bright Blue    on Black
      '             COLOR 13,0  ' Bright Magenta on Black
      '             COLOR 11,0  ' Bright Cyan    on Black
      '             COLOR 15,0  ' Bright White   on Black
      '             COLOR  7,0  '        White   on Black (standard DOS)

      ' Notes --------------------------------------------------------------------

      '  - Routine is intended for use in processing/conversion procedures running
      '    from DOS prompt and displaying processing messages on DOS screen.
      '  - Invalid usage of "%" delimiters could get message distorted; check in
      '    this case all instances of "%<code>%" entries.
      '  - Invalid color code is ignored.

      ' Example ------------------------------------------------------------------

      '    CALL PRNTCLR("%B%Batch command %C%tracing %B%mode is now %C%OFF%D%")

      ' External Function --------------------------------------------------------

           DECLARE FUNCTION TAILSTR$(Strng$,Delim$)

      ' Start Routine ------------------------------------------------------------

           DEFINT A-Z  ' All defaulted variables are integer

           SUB PRNTCLR(Text$)

      ' Print Colored Text to Screen ---------------------------------------------

           WHILE (LEN(Text$)>0)
                 IF (LEFT$(Text$,1)="%") THEN
                    IF (MID$(Text$,3,1)="%") THEN
                       Clr.Code$=MID$(Text$,2,1)
                       Text$=MID$(Text$,4)
                       IF (VERIFY(Clr.Code$,"RGYBMCWD")=0) THEN
                          IF (Clr.Code$="D") THEN
                             Clr.Numb=7
                          ELSE
                             Clr.Numb=8+INSTR("BGCRMYW",Clr.Code$)
                          END IF
                          COLOR Clr.Numb,0
                       END IF
                    ELSE
                       Text$=MID$(Text$,2)
                    END IF
                 ELSE
                    Text.Piece$=EXTRACT$(Text$,"%")
                    Text$      =TAILSTR$(Text$,"%")
                    IF (LEN(Text$)>0) THEN
                       Text$="%"+Text$
                    END IF
                    PRINT Text.Piece$;
                 END IF
           WEND

      ' Finish Routine ------------------------------------------------------------

           PRINT

           END SUB
  
         

 PRNTCLR  Debugging  Program                       Source program                   Debugging logout

      ' PRNTCLR(0.0)  Print Colored Text to Screen           09/25/1992-07/08/2005
      ' --------------------------------------------------------------------------

        $INCLUDE "PRNTCLR"
        $LINK    "MODULE.PBL"

        DECLARE SUB PRNTCLR(Text$)

        CLS
        PRINT "PRNTCLR(0.0)  Print Colored Text to Screen  ";DATE$;
        PRINT "  ";LEFT$(TIME$,5)
        PRINT STRING$(61,"-")
        PRINT

        CALL PRNTCLR("%G%PRNTCLR(0.0)     Color Codes Demo")
        CALL PRNTCLR("-----------------------------------")
        CALL PRNTCLR("%R%Bright Red:      R  - Error message")
        CALL PRNTCLR("%G%Bright Green:    G  - Title, info or disk name/letter")
        CALL PRNTCLR("%Y%Bright Yellow:   Y  - Command name or text accent")
        CALL PRNTCLR("%B%Bright Blue:     B  - Status message")
        CALL PRNTCLR("%M%Bright Magenta:  M  - Error message highlight")
        CALL PRNTCLR("%C%Bright Cyan:     C  - Key, status msg h/l or complex message")
        CALL PRNTCLR("%W%Bright White:    W  - Request or text highlight")
        CALL PRNTCLR("%D%Gray:            D  - DOS regular text")
        PRINT
        CALL PRNTCLR("%G%Several examples follow:%D%")
        PRINT
        CALL PRNTCLR("%W%Insert %G%DDDD %W%disk into floppy drive %G%A: %W%and hit %C%[Enter]%D%")
        CALL PRNTCLR("%W%Hit %C%[Enter] %W%to play %Y%next %W%tune or %C%[Esc] %W%to %Y%quit%D%")
        CALL PRNTCLR("%R%Wrong disk %M%XXXX %R%is inserted instead of requested %M%DDDD%D%")
        CALL PRNTCLR("%R%Free space on disk %M%DDDD %R%is only %M%12 %R%Kilobytes%D%")
        CALL PRNTCLR("%B%Batch command %C%tracing %B%mode is now %C%OFF%D%")
        CALL PRNTCLR("%G%Execution will take some time, please wait...%D%")
        CALL PRNTCLR("Reading source file(s)...")

        COLOR 7,0  ' Gray
        PRINT
        PRINT "Execution completed - hit [Enter] to continue..."
  
         

 PRNTCLR  Debugging  Logout                       Source program                   Debugging program

         

   PRNTCLR(0.0)  Print Colored Text to Screen  07-08-2005  18:39
   -------------------------------------------------------------

   PRNTCLR(0.0)     Color Codes Demo
   -----------------------------------
   Bright Red:       R  - Error message
   Bright Green:     G  - Title, info or disk name/letter
   Bright Yellow:    Y  - Command name or text accent
   Bright Blue:      B  - Status message
   Bright Magenta:   M  - Error message highlight
   Bright Cyan:      C  - Key, status msg h/l or compl message
   Bright White:     W  - Request or text highlight
   Gray:             D  - DOS regular text
Several examples follow:
Insert DDDD disk into floppy drive A: and hit [Enter] Hit [Enter] to play next tune or [Esc] to quit Wrong disk XXXX is inserted instead of requested DDDD Free space on disk DDDD is only 12 Kilobytes Batch command tracing mode is now OFF Execution will take some time, please wait... Reading source file(s)... Execution completed - hit [Enter] to continue...

         

View [and save] PRNTCLR.BAS text       View [and save] ZPRNTCLR.BAS text
(Use [Back] button or [Alt]+[CL] to return here from the viewed text)
Copyright © 1992–2005 by
Go to:  Davar site entry | Site contents | Site index | Personal Computer | PowerBASIC | Text top