' 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 "%%". ' 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 Prompt 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 "%%" 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