1.2.7A BASICexample
Here’sanexampleyou cantypein rightnow,to clarifywhatwe’re saying.
It’s writtenin Microsoft BASICfor acomputer thatuses the MS-DOS
operatingsystem,so if youhave adifferentcomputeror BASICyoumay
havetotranslateabit.We’ll showcommandsthewaythey’rewrittenforan
Epsondot-matrixprinterbecauseyourStarLaserPrinter4understandsthose
commands.
TheLPRINTcommandsallsenddatato theprinter.Ifthe dataissomething
youwant printedyoujust putit in quotationmarks.If the datais acontrol
codeyoujustsaywhexeitisintheASCIItable,givingitspositionasaregular
decimalnumber.
BASICusuallysendsacarriagereturnafterevery80character, to keepthe
print positionmovingwhenit hits theend ofaline. Unasked-forcarriage
returnscanmess up yourprinting,however,so it’s agoodhabitto put ina
WIDTHstatementas shown.Thatlets us printover thewholepage area.
The<BEL>controlcode—ASCIIcode7—is sentin BASICasCHR$(7).
ThecESG codeitselfisCHR$(27).Andbecausewe’reusingthecharacter
4aspart of an cESC>command,we typeCHR$(52)insteadof “4”.
Soif you startBASIC andtypethese commands:
NEW
10 ‘ EXAMPLE
20 WIDTH “LPT1:“,255
30 LPRINTCHR$(7)
40 LPRINTCHR$(27);CHR$(52)
50 LPRINT“ITALICS!“
60 END
RUN
youmaketheprinter(inFX-850mode)firstsounditsbell-most peoplecall
itabeeper— andthenprint theline:
ITALICS!
Generally,whenyousendacontrolor Escapecodeit staysactiveuntilyou
deactivateit.That’s what happensin line40 of our program above.All
subsequenttextwillbe italicizeduntilyouchangeit backto uprightagain.
10