home *** CD-ROM | disk | FTP | other *** search
- This hint outlines how to modify the standard report skeleton to allow
- reports to the "CON" device, (the screen), to use ASNI escape sequences
- thus adding a bit of color to the report.
-
- NOTE THAT TO BE ABLE TO USE ANSI ESCAPE CODE YOU MUST HAVE ANSI.SYS LOADED!
-
-
- To build these improvements in as seemlessly as possible we will look for
- the "Screen Printer Definition" in a file of a different name the that
- usually used, (ANSIPRT.DEF rather than DBPRINT.DEF). This way it won't be
- necessary to keep running the printer installation every time you want to
- swap printing a report to/from the screen and some other device, (printer
- or disk file).
-
- 1) Copy the standard report skeleton, (DBCREP.SKL), to a new file where we
- can feel safe making the changes, (DBCREPA.SKL).
-
- COPY DBCREP.SKL DBCREPA.SKL
-
-
- 2) Now to make some modifications to our new skeleton. First we need to
- introduce another intiialized string at the top of the skeleton, this is
- the name of the printer definition file if the output device is "CON".
- We'll add this directly after the standard printer definitino file name...
-
- STRING PRT_DEFN_NAME = "DBPRINT.DEF";
- STRING CON_DEFN_NAME = "ANSIPRT.DEF"; /* <-- Add this line */
-
-
- 3) The next change is to the "getPrinterCodes()" function. Currently this
- function automatically returns null/empty printer escape sequences if the
- output device in "CON", (so that normal printer codes don't end up all
- over the screen).
-
- Modify the line
-
- if (!strstr(iodev, "CON") && !strstr(iodev, "DSK")) {
-
- To
-
- if (!strstr(iodev, "DSK")) {
-
-
- 4) In a similar manner the "outputLine" function does not attempt to process
- printer codes if the output device in the "CON". In this case we can
- remove then opening "if.. else { " clause and it's associated "}"
-
- There is also another small alteration in the "outputLine" function, this
- is the swapping of the lines :--
-
- outputPrinterCodes(strip(tempString1, printerCodePtr->on), 1);
- outputPrinterCodes(strip(tempString1, printerCodePtr->off), 0);
-
- In the modified exert below these are swapped so that "OFF" codes are
- processed before "ON" codes, it is important to do this because the
- different "color" codes are not "additive".
-
-
- void outputLine(PAGELINE aLine)
- {
- BYTE lastCodePos;
- PCODEPTR printerCodePtr;
- STRING tempString1, tempString2, tempString3;
-
- *tempString1 = *tempString2 = *tempString3 = NULL_CH;
- /*
- if (strstr(iodev, "CON") && !pabort) chkwrite(outputFileHandle, strcopy(tempString1, aLine.line, 0, 79), ad_crlf);
- else {
- */ /* MOD ANSIPRT remove the above test */
- lastCodePos = 0;
- printerCodePtr = aLine.pcodes;
- while (printerCodePtr) {
- if (!pabort) chkwrite(outputFileHandle, filterstr(tempString2, linebit(tempString1, aLine.line, lastCodePos, printerCodePtr->xpos - 1), pmode), no_crlf);
- lastCodePos = printerCodePtr->xpos;
- outputPrinterCodes(strip(tempString1, printerCodePtr->off), 0);
- /*MOD ANSIPRT */ /* remember to move "off" up above "on" */
- outputPrinterCodes(strip(tempString1, printerCodePtr->on), 1);
- printerCodePtr = printerCodePtr->nxtp;
- }
- if (!pabort) chkwrite(outputFileHandle, filterstr(tempString3, trim(tempString1, linebit(tempString2, aLine.line, lastCodePos, strlen(aLine.line) - 1)), pmode), ad_crlf);
- /* } */ /* MOD ANSIPRT */
- return;
- }
-
-
- 5) The final change to make is in the "readPrinterCodesFile()" function.
- Here we just need to test the output device, and if it is the "CON" then
- read the printer codes from "ANSIPRT.DEF" instead of "DBPRINT.DEF". As
- both the file names are defined as initialized strings use the local
- "tempString" to store the name depending on the device name :--
-
- void readPrinterCodesFile(void)
- {
- uchar codeslen;
- FILE *printerCodesFile; /* file of STYLEREC */
- STYLEREC printerCodesRecord;
- PRTCTRLREC startLinkListPtr, nextLinkListPtr;
- STRING tempString;
-
- startLinkListPtr = NULL;
-
- /* START MOD ANSIPRT */
- if (strstr(iodev, "CON")) /* Test output device */
- strcpy(tempString,CON_DEFN_NAME); /* this one for "CON" */
- else /* otherwise */
- strcpy(tempString,PRT_DEFN_NAME); /* use the usual one */
- printerCodesFile = fopen(tempString,"rb");/* Open name in tempString */
- if (!printerCodesFile) /* May need to look elsewhere */
- printerCodesFile = fopen(strconcat(tempString, thisprog.fdir, tempString,NULL), "rb");
- /* END MOD ANSIPRT */
-
- if (printerCodesFile) {
- ...
-
-
- 6) With all the above changes made you simply need to change the skeleton
- name when you "GENERATE" the report from DBCREP.SKL to DBCREPA.SKL, and
- all the changes will end up in the final program.
-
- 7) The last step is to create the "ANSIPRT.DEF" printer definition file. To
- do this run the "Printer Installation" utility and "A"dd a new printer,
- (let's call it "ANSI Console").
-
- Press the "+" key to swap to the control codes screen and add in the
- codes you want to use. Here is a simple example of some escape sequences
- that you could use.
-
- ID Description ON OFF
- --- --------------- -------------------- --------------------
- N Normal ESC,'[0;37;40m' ESC,'[0;37;40m'
- C Compressed ESC,'[1;37;40m' ESC,'[0;37;40m'
- R Reset ESC,'[0;37;40m' ESC,'[0;37;40m'
- B Bold ESC,'[1;33;40m' ESC,'[0;37;40m'
- E Enhanced ESC,'[1;31;40m' ESC,'[0;37;40m'
-
- Finally press "-" to get back to the first screen and "Select" the new
- printer definition, change the anem from "DBPRINT.DEF" to "ANSIPRT.DEF"
- and that just about does it.
-
-
- SOME ANSI ATTRIBUTES/COLORS
- ===========================
- 0 - All attribures off
- 1 - High Intensity Foreground
- 4 - Underscore, (Monochrome display cards only)
- 5 - Blinking Background
- 7 - Reverse video
- 8 - Concealed
-
- 30 - Black Foreground 40 - Black Background
- 31 - Red Foreground 41 - Red Background
- 32 - Green Foreground 42 - Green Background
- 33 - Yellow Foreground 43 - Yellow Background
- 34 - Blue Foreground 44 - Blue Background
- 35 - Magents Foreground 45 - Magents Background
- 36 - Cyan Foreground 46 - Cyan Background
- 37 - White Foreground 47 - White Background
-