PRNTCLR PowerBASIC (32-bit) 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 output of SETCOLOR Take Command batch script, color codes and syntax of which have been used in PRNTCLR routine. Direct dependency:
PRNTCLR Source Program Debugging program Debugging logout |
' PRNTCLR(2.0) Print Colored Text to Screen 09/25/1992-02/19/2010 ' ------------------------------------------------------------------------------ ' Copyright (C) 1992-2010 by Vladimir Veytsel www.davar.net ' Type ------------------------------------------------------------------------- ' Routine ' Parameters ------------------------------------------------------------------- ' 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 P Promtp 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 (Prompt standard) ' Skip% - Skip to the next line flag: ' 1 - Skip to the next line (any non-zero value stands for the same) ' 0 - Don't skip ' Notes ------------------------------------------------------------------------ ' - Routine is intended for use in processing/conversion procedures running ' from command prompt and displaying processing messages on the screen. ' - Invalid usage of "%" delimiters could get message distorted; check in this ' case all instances of "%<code>%" entries. ' - Invalid color codes are ignored. ' - Though origins of this program are different, in the current form it's an ' imitation of Take Command batch script SETCOLOR that permits easy coloring ' of processing messages that are being displayed by batch scripts on the ' screen. ' - PowerBASIC (as well as any BASIC) color settings are rather bulky, and each ' color switch requires separate COLOR operator - too much of a trouble, IMHO, ' to be worth of the result. ' - PRNTCLR routine permits to insert short and easy to handle color codes right ' into the messages being displayed, making coloring a relatively easy effort ' often worth to try. ' Example ---------------------------------------------------------------------- ' CALL PRNTCLR("%B%Batch script %C%tracing %B%mode is now %C%OFF%P%",1) ' External Function ------------------------------------------------------------ #INCLUDE ONCE "TAILSTR" ' Start Routine ---------------------------------------------------------------- DEFINT A-Z ' All defaulted variables are integer SUB PRNTCLR(Text$,Skip%) ' 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$,"RGYBMCWP")=0) THEN IF (Clr_Code$="P") 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 IF (Skip%<>0) THEN PRINT ' Finish Routine ---------------------------------------------------------------- COLOR 7,0 ' Restore Gray on Black END SUB
PRNTCLR Debugging Program Source program Debugging logout |
' PRNTCLR(2.0) Print Colored Text to Screen 09/25/1992-02/19/2010 ' ------------------------------------------------------------------------------ #INCLUDE "PRNTCLR" FUNCTION PBMAIN PRINT "PRNTCLR(2.0) Print Colored Text to Screen ";DATE$; PRINT " ";LEFT$(TIME$,5) PRINT STRING$(61,"-") PRINT CALL PRNTCLR("%G%PRNTCLR(2.0) Color Codes Demo and Usage Examples",1) CALL PRNTCLR("%G%-------------------------------------------------",1) CALL PRNTCLR("%R%Bright Red: R - Error message",1) CALL PRNTCLR("%G%Bright Green: G - Title, info or disk name/letter",1) CALL PRNTCLR("%Y%Bright Yellow: Y - Command name or text accent",1) CALL PRNTCLR("%B%Bright Blue: B - Status message",1) CALL PRNTCLR("%M%Bright Magenta: M - Error message highlight",1) CALL PRNTCLR("%C%Bright Cyan: C - Key, status msg h/l or complex message",1) CALL PRNTCLR("%W%Bright White: W - Request or text highlight",1) CALL PRNTCLR("%P%Gray: P - Prompt regular text",1) PRINT CALL PRNTCLR("%G%Several usage examples follow:",1) PRINT CALL PRNTCLR("%W%Insert %G%DDDD %W%disk into floppy drive %G%A: %W%and hit %C%[Enter]",1) CALL PRNTCLR("%W%Hit %C%[Enter] %W%to play %Y%next %W%tune or %C%[Esc] %W%to %Y%quit",1) CALL PRNTCLR("%R%Wrong disk %M%XXXX %R%is inserted instead of requested %M%DDDD",1) CALL PRNTCLR("%B%Batch command %C%tracing %B%mode is now %C%OFF",1) CALL PRNTCLR("%G%Execution will take some time, please wait...%P%",1) CALL PRNTCLR("Reading source file(s)...",1) PRINT CALL PRNTCLR("%G%Compound message example:",1) PRINT CALL PRNTCLR("%R%Red - ",0) CALL PRNTCLR("%G%Green - ",0) CALL PRNTCLR("%Y%Yellow - ",0) CALL PRNTCLR("%B%Blue - ",0) CALL PRNTCLR("%M%Magenta - ",0) CALL PRNTCLR("%C%Cyan - ",0) CALL PRNTCLR("%W%White - ",0) CALL PRNTCLR("%P%Gray",1) END FUNCTION
PRNTCLR Debugging Logout Source program Debugging program |
PRNTCLR(2.0) Print Colored Text to Screen 09-24-2016 12:31 ------------------------------------------------------------- PRNTCLR(2.0) Color Codes Demo and Usage Examples ------------------------------------------------- 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: P - Prompt regular text |
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–2010 by Go to: Davar site entry | Site contents | Site index | Personal Computer | PowerBASIC | Text top |