A BASIC example
Here’s an example you can typo in right now, to clarify what we’re saying.
It’s
writtenin MicrosoflBASIC for a computerthat uses the MS-DOS
operatingsystem,so if youhavea differentcomputeror BASICyou may
haveto translateabit.We’11showcommandsthewaythey’rewrittenforan
Epsondot-matrixprinterbecauseyourStarLaserPrinter8understandsthose
commands.
TheLPRINTcommandsallsenddatatotheprinter.Ifthedataissomething
youwantprintedyoujust putit in quotationmarks.If thedatais a control
codeyoujustsaywhereitisintheASCIItable,givingitspositionasaregular
decimalnumber.
BASICusuallysendsacarnagereturnafterevery80characters,to keepthe
print positionmovingwhenit hitstheend of a line.Unasked-forcarriage
returnscanmessup yourprinting,however,so ii’s a goodhabitto putin a
WIDTHstatementas shown.Thatletsus printoverthe wholepagearea.
The<BEL>controlcode—ASCIIcode7— issentinBASICasCHR$(7).
The<ESC>codeitselfisCHR$(27).Andbecausewe’reusingthecharacter
4 as
part of an <ESC>command,we typeCHR$(52)insteadof “4”.
So if youstartBASICand typethesecommands:
NEW
10 ‘ EXAMPLE
20 tiIDTH “LPT1 :”, 255
30 LPRINT CHR$(7)
40 LPRINT CHR$(27) ;CHR$(52)
50 LPRINT “ITALICS ! “
60 END
RUN
youmakethe printer(in EX-800mode)firstsoundits bell—mostpeople
callit a beeper—andthenprintthe line:
ITALICS!
Generally,whenyousenda controlorEscapecodeit staysactiveuntilyou
deactivateit. That’swhathappensin line 40 of our programabove.All
subsequenttextwillbeitalicizeduntilyouchangeit backto uprightagain.
10