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