BBS: Inland Empire Archive Date: 04-09-92 (16:15) Number: 28 From: ERIC FOARD Refer#: NONE To: ALL Recvd: NO Subj: Color to ANSI coversion S Conf: (2) Quik_Bas
DECLARE SUB writeln (FORCOLOR!, BCKCOLOR!, TEXT$) SCREEN 0, 0, 0, 0: WIDTH 80, 25 REM THIS PROGRAM CONVERTS QuickBasic COLOR TO ANSI CODES REM AND OUTPUTS THEM TO SCREEN AND #1 REM PUT YOUR OUTPUT HERE OPEN "D:\QB45\AA\TEST.ANS" FOR OUTPUT AS #1 OPEN "CON" FOR OUTPUT AS #2 RANDOMIZE TIMER START: FOR MAKECOLORS = 1 TO 256 FOR MCKCLR = 1 TO 8 CHARNUM = INT(RND * 224) + 32'PICK A CHAR TEXT$ = TEXT$ + CHR$(CHARNUM)'CONVERT CHAR# TO TEXT STRING NEXT MCKCLR FORCOLOR = INT(RND * 31) + 1 'PICK FOREGROUND COLOR BCKCOLOR = INT(RND * 8) 'PICK BACKGROUND COLOR writeln FORCOLOR, BCKCOLOR, TEXT$ TEXT$ = "" NEXT MAKECOLORS CLOSE END SUB writeln (FORCOLOR, BCKCOLOR, TEXT$) FCOLOR = FORCOLOR BCOLOR = BCKCOLOR ANSISTR$ = CHR$(27) + "[0;" IF FCOLOR > 7 AND FCOLOR < 16 THEN ANSISTR$ = ANSISTR$ + "1;" 'BOLD IF FCOLOR > 23 THEN ANSISTR$ = ANSISTR$ + "1;" 'BOLD WHILE BLINK IF FCOLOR > 15 THEN ANSISTR$ = ANSISTR$ + "5;" 'BLINK IF FCOLOR > 7 THEN FCOLOR = FCOLOR - 8 IF FCOLOR > 7 THEN FCOLOR = FCOLOR - 8 IF FCOLOR > 7 THEN FCOLOR = FCOLOR - 8 IF FCOLOR = 0 THEN ANSISTR$ = ANSISTR$ + "30;" 'BLACK IF FCOLOR = 1 THEN ANSISTR$ = ANSISTR$ + "34;" 'BLUE IF FCOLOR = 2 THEN ANSISTR$ = ANSISTR$ + "32;" 'GREEN IF FCOLOR = 3 THEN ANSISTR$ = ANSISTR$ + "36;" 'CYAN IF FCOLOR = 4 THEN ANSISTR$ = ANSISTR$ + "31;" 'RED IF FCOLOR = 5 THEN ANSISTR$ = ANSISTR$ + "35;" 'MAGENTA IF FCOLOR = 6 THEN ANSISTR$ = ANSISTR$ + "33;" 'YELLOW IF FCOLOR = 7 THEN ANSISTR$ = ANSISTR$ + "37;" 'WHITE IF BCOLOR = 0 THEN ANSISTR$ = ANSISTR$ + "40m" 'BLACK IF BCOLOR = 1 THEN ANSISTR$ = ANSISTR$ + "44m" 'BLUE IF BCOLOR = 2 THEN ANSISTR$ = ANSISTR$ + "42m" 'GREEN IF BCOLOR = 3 THEN ANSISTR$ = ANSISTR$ + "46m" 'CYAN IF BCOLOR = 4 THEN ANSISTR$ = ANSISTR$ + "41m" 'RED IF BCOLOR = 5 THEN ANSISTR$ = ANSISTR$ + "45m" 'MAGENTA IF BCOLOR = 6 THEN ANSISTR$ = ANSISTR$ + "43m" 'YELLOW IF BCOLOR = 7 THEN ANSISTR$ = ANSISTR$ + "47m" 'WHITE ANSISTR$ = ANSISTR$ + TEXT$ REM COLOR FORCOLOR, BCKCOLOR: PRINT TEXT$; PRINT #1, ANSISTR$; PRINT #2, ANSISTR$; END SUB --- * Origin: The Enterprise Board Line #2 (1:282/60)
Books at Amazon:
Back to BASIC: The History, Corruption, and Future of the Language
Hackers: Heroes of the Computer Revolution (including Tiny BASIC)
Go to: The Story of the Math Majors, Bridge Players, Engineers, Chess Wizards, Scientists and Iconoclasts who were the Hero Programmers of the Software Revolution
The Advent of the Algorithm: The Idea that Rules the World
Moths in the Machine: The Power and Perils of Programming
Mastering Visual Basic .NET