' ========================================================================== ' REMEMBER ANSI.SYS? ' ' Remember ANSI.SYS? Do you still have it loading in your config.sys in ' spite of the fact that it doesn't really do anything? Well, it does do ' something, actually, but like Wow, who cares. I don't think anyone's ' impressed anymore. I haven't seen anyone fighting to develop a ' Turbo-ANSI.SYS (or a Turbo-EDLIN for that matter. EDLIN for Windows. ' WINEDLIN 6.0. Hmmmm...). Anyway, here are some PowerBASIC routines that ' will allow you to do some interesting things with the little buggar: OPEN "CONS:" FOR OUTPUT AS #1 ' Let's leave F1-F3 alone 'PRINT #1,CHR$(27) + "[0;59;" + CHR$(34) + "" + CHR$(34) +";13p" 'PRINT #1,CHR$(27) + "[0;60;" + CHR$(34) + "" + CHR$(34) +";13p" 'PRINT #1,CHR$(27) + "[0;61;" + CHR$(34) + "" + CHR$(34) +";13p" ' Let's use F4-F10 for our own purposes! PRINT #1,CHR$(27) + "[0;62;" + CHR$(34) + "DIR" + CHR$(34) +";13p" PRINT #1,CHR$(27) + "[0;63;" + CHR$(34) + "CHKDSK" + CHR$(34) +";13p" PRINT #1,CHR$(27) + "[0;64;" + CHR$(34) + "FORMAT A:" + CHR$(34) +";13p" PRINT #1,CHR$(27) + "[0;65;" + CHR$(34) + "CD \PB3" + CHR$(34) +";13p" PRINT #1,CHR$(27) + "[0;66;" + CHR$(34) + "VIDRAM ON" + CHR$(34) +";13p" PRINT #1,CHR$(27) + "[0;67;" + CHR$(34) + "BACKUP C: A:" + CHR$(34) +";13p" PRINT #1,CHR$(27) + "[0;68;" + CHR$(34) + "PARK" + CHR$(34) +";13p" CLOSE #1 ' Notice that the PRINT# statements are outputting extended scan codes ' within the ANSI escape sequence. You can use any scan code and redefine ' any key on the keyboard, not just function keys, like 0;45 for ALT-X, etc. ' The ;13 appends a carriage return and can be omitted if desired. Bonus. ' ' Well, that's all neat, but ANSI can also be useful in how it handles ' console redirection. You can write a program that sends output to the ' CONS device that can then be redirected to a file (for making BBS screens) ' or to the communications port for creating a BBS door or for controling ' your computer from a terminal (some people actually do that). The ' following routines are similar to BASIC's CLS, LOCATE and COLOR statements. ' The only difference is ANSICOLOR, which must accept color codes from the ' table which follows the routines. SUB ANSICLS CALL ANSIPRINT(CHR$(27)+"[2J"+CHR$(27)+"[;f") END SUB SUB ANSILOCATE (row, col) CALL ANSIPRINT(CHR$(27)+"["+MID$(STR$(row),2)+";"+MID$(STR$(col),2)+"f") END SUB SUB ANSICOLOR (fg, bg) CALL ANSIPRINT(CHR$(27)+"["+MID$(STR$(row),2)+";"+MID$(STR$(col),2)+"m") END SUB SUB ANSIPRINT(Text$) OPEN "CONS:" FOR OUTPUT AS #1 PRINT #1, Text$ CLOSE #1 END SUB ' ANSICOLOR color codes: ' ' The first four can be used in any position (foreground or ' background) or can be doubled up if they do not accompany ' a color code, like CALL ANSICOLOR(7,7) ' ' 0 - all attributes off ' 4 - underlined text ' 5 - flashing text ' 7 - inverse text ' ' These are the color you must use to generate ANSI color: ' ' Foreground Background ' 30 - Black 40 - Black ' 31 - Red 41 - Red ' 32 - Green 42 - Green ' 33 - Yellow 43 - Yellow ' 34 - Blue 44 - Blue ' 35 - Magenta 45 - Magenta ' 36 - Cyan 46 - Cyan ' 37 - White 47 - White