Using Control Codes From BASIC Faxback Doc. # 4002 Experienced programmers can use printer control codes to write programs that control printer operation (rather than using application software). These programs can: * Print character enhancements (such as double-strike and bold print) * Create graphic images * Set margins or adjust line spacing Character and Graphics Modes: Most printers are designed for two printing modes--characters and graphics. Both modes use some similar control code sequences. However, many of the control codes used to print characters do not work in the graphics mode. The printer does not show an error message when you send one of these control codes; it simply ignores it. Some examples are control codes that change line-feed pitch and direction. Computer-to-Printer Communication: Control codes are numbers between 0 and 255 decimal (00-FF hexadecimal) that the computer sends to the printer. The printer interprets these numbers (or codes) and prints them as letters, numbers, or symbols. You can also use the numbers 0-31, as well as some special sequences of code numbers, to program various printer functions. These sequences let you change character sets, select print modes, underline, superscript, subscript, and perform other special functions. Control codes can take two forms. There are one-byte codes line the FF and LF codes, and there are also codes preceded by ESC, called escape codes, that require additional bytes to further define the required action. Sending Control Codes from Basic: You can activate some printer features by sending a single code, but many functions require a sequence of two or more codes. Most multiple-code sequences begin with decimal 27, referred to as the ESC (escape) code. The ESC code notifies the printer that another special code is on its way. The next code(s) sent selects the printer feature. The following example uses BASIC's CHR$() function to send a multiple-code sequence to the printer. Note: Example is for an IBM compatible dot matrix printer. Specific control code information is available for each printer. Set up the printer and enter BASIC in the normal way. Then type and run the following program: 10 LPRINT "HALF LINE";CHR$(27);"J";CHR$(24); 20 LPRINT "FEEDING" Roll the paper forward and look at the result. The word FEEDING is printed just below HALF LINE with half line spacing, because the codes CHR$(27);"J";CHR$(24) tell the printer to change the forward line feed to 24/216" (1/9"), which is half of the normal distance. Note: Results vary, depending on the LF or CR function switch setting in your printer. If you activated the MS-DOS LF command, this could also cause a different result. (jej-04/22/94)