BBS: Inland Empire Archive Date: 06-13-92 (19:46) Number: 305 From: JEAN CREPEAU Refer#: NONE To: CHARLIE QUANTE Recvd: NO Subj: An Interesting Little Fun Conf: (2) Quik_Bas
In a message to ALL, CHARLIE QUANTE wrote: CQ=> I dink around writing doors for BBS's, and have had a need in the past to add ANSI colors to various bulletins files. At first I was using a fifteen element string array, with each element containing the ANSI codes for that color. For example: C$(1) = CHR$(27) + "[;34;40m" CQ=> Then when I wanted to add a color to a line of text being sent to a file, I did something like: PRINT #1, C$(1) + LN$ CQ=> I've come up with a neat little function call that does away with the array completely: CQ=> FUNCTION ANSI$(X) ... CQ=> END FUNCTION CQ=> To add an ansi color to a line being saved I just: CQ=> Can someone familiar with D'Bridge share the secret of loading an ascii as a message? That way I don't have to type each example? You program is not bad, but there is a simpler way to do what you want to do. The ANSI color numbers follow a rule color = Red + 2*Green + 4*Blue + 30*FG + 40*BG The CGA color coding is color = Blue + 2*Green + 4*Red + 8*HI Therefore, the color translation should be something simpler than your program. FUNCTION ANSICOLOR$(FG,BG) CONST CLR2ANSI$="04261537" U$=CHR$(27)+"[;" IF FG AND 8 THEN U$=U$+"1;" ' HIGHLIGHTE ATTRIBUTE IF FG AND 16 THEN U$=U$+"5;" ' BLINK ATTRIBUTE ANSICOLOR$=U$ + "3" + MID$(CLR2ANSI$,(FG AND 7)+1,1) + ";4" +_ MID$(CLR2ANSI$,(BG AND 7)+1,1) +"M" END FUNCTION This function accepts exactly the same parameters as the COLOR statement. Jean --- * Origin: INTERACESS Montreal (QC) Canada (514) 528-1415 (1:167/280)
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