diff options
Diffstat (limited to 'web/clip/vax_vms/ex01_a.ps')
-rw-r--r-- | web/clip/vax_vms/ex01_a.ps | 1419 |
1 files changed, 1419 insertions, 0 deletions
diff --git a/web/clip/vax_vms/ex01_a.ps b/web/clip/vax_vms/ex01_a.ps new file mode 100644 index 0000000000..196a5f6707 --- /dev/null +++ b/web/clip/vax_vms/ex01_a.ps @@ -0,0 +1,1419 @@ +%!PS-Adobe-2.0 +%%DocumentFonts: (atend) +%%Title: F:\\LPT\\VMS\\EX01_A.DOC +%%Creator: Lotus Manuscript +%%For: EWvA, MRK +%%CreationDate: September 29, 1993 +%%Pages: (atend) +%%BoundingBox: 0 0 595 841 +%%EndComments +% PostScript Prologue (initialization) for Manuscript +% Copyright (c) 1985,1986,1987,1988 Lotus Development Corporation +% There is no user servicable code in this file. + +% set timeouts to infinite +statusdict begin +0 setjobtimeout +/manualfeedtimeout 3600 def +/waittimeout 0 def +end + +% correct bug correction in rev 41.0 +/idiv{div cvi}bind def + +% define User Dictionary +/msdict 300 dict def msdict begin +/bd{bind def}bind def + +% Define commonly used things +/delay{usertime 5000 add{dup usertime lt{pop exit}if}loop}bd +/mfeed{statusdict begin /manualfeed true def end}bd +/afeed{statusdict begin /manualfeed false def end}bd +/bfeed{ afeed statusdict begin /setpapertray where + {pop setpapertray}{pop} ifelse end}bd + +/dpi{0.24 dup scale}bd + +% These two are called for each page +/inpage false def +/begpage{save dpi /inpage true def}bd +/endpage{inpage {restore showpage}if }bd + +% for possible banner +/fileinfo {pop pop pop}bd +/enddocument {end} bd + +% these are also used by eqn & gmf +/ld{load def}bd +/x/exch ld +/cu{300 mul 72 div}bd +/m/moveto ld +/t/translate ld +/rm/rmoveto ld +/cp/currentpoint ld +/st/stroke ld +/ln/lineto ld +/rlt/rlineto ld +/slw/setlinewidth ld + +/ff/findfont ld +/scf/scalefont ld +/sf/setfont ld +/fs{x /pt x def ff pt cu scf sf}bd + +% linedraw +/li{4 2 roll setlinewidth 3 1 roll moveto 0.0 rlineto st}bd + +% outline factor +/olwid 40.0 def +% stroke width for outline +/uoslw {pt cu x div slw}bd +% relative horizontal move +/xm{x currentpoint pop sub 0.0 rmoveto}bd + +% The basic show +/s/show ld +% move horizontal and show +/ms{xm s}bd + +% variations +% outline show - first printer attribute +/ppss{dup cp 3 -1 roll false charpath st +x 3 -1 roll stringwidth pop add x moveto}bd +/pss{olwid uoslw { ( ) dup 0 4 -1 roll put ppss}forall}bd +/ps{pss}bd +/mps{xm ps}bd + +% graybox show - second printer attribute +/gb{cp 3 -1 roll pt cu dup 4 div neg 0 x rm dup 0 x rlt x 0 rlt +neg 0 x rlt closepath currentgray .9 setgray fill setgray m}bd +/usi{dup stringwidth pop gb}bd +/us{usi s}bd +/xum{x cp pop sub dup gb 0 rmoveto}bd + +% combinations of PD1 and PD2 +/ups{usi pss}bd +/mups{xm ups}bd +/mus{xm us}bd + +% define a new encoding vector (code page 850 based) +/PC 256 array def +StandardEncoding PC copy pop + +/dotaccent/bullet +/quotesingle/quotedblleft/quotedblright/quotesinglbase +/quotedblbase/guilsinglleft/guilsinglright/.notdef +/ellipsis/perthousand/.notdef/.notdef/paragraph/section/dagger/daggerdbl +/OE/oe/fi/fl/endash/emdash/fraction/Ydieresis +PC 6 26 getinterval astore pop + +/Ccedilla/udieresis/eacute/acircumflex/adieresis/agrave/aring/ccedilla +/ecircumflex/edieresis/egrave/idieresis/icircumflex/igrave/Adieresis/Aring +/Eacute/ae/AE/ocircumflex/odieresis/ograve/ucircumflex/ugrave +/ydieresis/Odieresis/Udieresis/oslash/sterling/Oslash/.notdef/florin +/aacute/iacute/oacute/uacute/ntilde/Ntilde/ordfeminine/ordmasculine +/questiondown/.notdef/.notdef/onehalf/onequarter/exclamdown/guillemotleft/guillemotright +/.notdef/.notdef/.notdef/.notdef/.notdef/Aacute/Acircumflex/Agrave +/.notdef/.notdef/.notdef/.notdef/.notdef/cent/yen/.notdef +/.notdef/grave/.notdef/circumflex/tilde/.notdef/atilde/Atilde +/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/currency +/eth/Eth/Ecircumflex/Edieresis/Egrave/dotlessi/Iacute/Icircumflex +/Idieresis/.notdef/.notdef/.notdef/.notdef/brokenbar/Igrave/.notdef +/Oacute/germandbls/Ocircumflex/Ograve/otilde/Otilde/.notdef/thorn +/Thorn/Uacute/Ucircumflex/Ugrave/yacute/Yacute/.notdef/acute +/.notdef/.notdef/.notdef/threequarters/paragraph/section/.notdef/cedilla +/ring/dieresis/periodcentered/onesuperior/threesuperior/twosuperior/.notdef/.notdef + +PC 128 128 getinterval astore pop + +% duplicate fonts with a new encoding vector +/recd 5 dict def +/pcft +{recd begin +/ncs PC def /nfn x def +/bfn x def /bfd bfn findfont def +/nf bfd maxlength dict def +bfd{x dup dup /FID ne x /Encoding ne and +{x nf 3 1 roll put}{pop pop}ifelse +}forall +nf/FontName nfn put +nf/Encoding ncs put +nfn nf definefont pop +end}bd + +/fs{x /pt x def ff pt cu scf sf}bd + +% used by eqn +/Times-Roman/TR pcft /Times-Bold/TRB pcft +/Times-Italic/TRI pcft /Times-BoldItalic/TRBI pcft +/Helvetica/HV pcft /Helvetica-Bold/HVB pcft +/Helvetica-Oblique/HVO pcft /Helvetica-BoldOblique/HVBO pcft +/Courier/CR pcft /Courier-Bold/CRB pcft +/Sym{/Symbol fs}bd + +% Bit map image data decompression code +/xx 0 def /yy 0 def +/xbytes 0 def +/lbuf 1200 string def /obuf 600 string def +/bval <FFFEFCF8F0E0C080000103070F1F3F7F> def +/blacks 96 string def /whites 96 string def +0 1 95 {whites x 255 put} for + +/dispatch [ +{ +dup 47 le {32 sub 4 bitshift x pop 1}{ +dup 63 le {x pop 48 sub bval x get +3 copy put x 1 add x 0} { +dup 79 le {62 sub} { +80 sub { 3 copy put x 1 add x } repeat 0 +}ifelse }ifelse }ifelse +}bind +{ +32 sub add +3 copy put +x 1 add x 0 +} bind +{ +32 sub x pop add 255 0 +}bind +{ +32 sub x pop +3 copy getinterval +whites 0 3 index getinterval +x copy pop add 255 0 +}bind +{ +32 sub x pop +3 copy getinterval +blacks 0 3 index getinterval +x copy pop add 0 0 +}bind +]def + +% read a raster line and unpack +/readx{ +obuf 0 255 0 +currentfile lbuf readline pop +{x dispatch x get exec} forall +pop pop pop 0 xbytes getinterval}bd + +/mspic{ +/yy x def/xx x def +/xbytes xx 8 idiv def +xx yy 1 [xx 0 0 0 yy sub 0 yy]{readx}image}bd + + + +/Helvetica/fA pcft/FA{/fA fs}bd +/Helvetica-Oblique/fAI pcft/FAI{/fAI fs}bd +/Helvetica-Bold/fAB pcft/FAB{/fAB fs}bd +/Helvetica-BoldOblique/fAIB pcft/FAIB{/fAIB fs}bd +/Times-Roman/fB pcft/FB{/fB fs}bd +/Times-Italic/fBI pcft/FBI{/fBI fs}bd +/Times-Bold/fBB pcft/FBB{/fBB fs}bd +/Times-BoldItalic/fBIB pcft/FBIB{/fBIB fs}bd +/Courier/fH pcft/FH{/fH fs}bd +/Courier-Oblique/fHI pcft/FHI{/fHI fs}bd +/Courier-Bold/fHB pcft/FHB{/fHB fs}bd +/Courier-BoldOblique/fHIB pcft/FHIB{/fHIB fs}bd +/ZapfChancery-MediumItalic/fL pcft/FL{/fL fs}bd +/ZapfChancery-MediumItalic/fLI pcft/FLI{/fLI fs}bd +/ZapfChancery-MediumItalic/fLB pcft/FLB{/fLB fs}bd +/ZapfChancery-MediumItalic/fLIB pcft/FLIB{/fLIB fs}bd +/AvantGarde-Book/fM pcft/FM{/fM fs}bd +/AvantGarde-BookOblique/fMI pcft/FMI{/fMI fs}bd +/AvantGarde-Demi/fMB pcft/FMB{/fMB fs}bd +/AvantGarde-DemiOblique/fMIB pcft/FMIB{/fMIB fs}bd +(F:\\LPT\\VMS\\EX01_A.DOC)(EWvA, MRK)(September 29, 1993)fileinfo +%%EndProlog +%%Page: 0 1 +begpage +12 FAB +977 2996 m +(Example 01: Palindrome filter)s +12 FB +295 2669 m +(In)s +354(this)ms +444(appendix)ms +645(we)ms +721(illustrate)ms +914(the)ms +993(CLiP)ms +1117(style)ms +1229(of)ms +1289(literate)ms +1445(programming)ms +1735(by)ms +1803(a)ms +1843(program)ms +2031(to)ms +2087(filter)ms +295 2609 m +(palindromic)s +549(lines)ms +656(from)ms +765(an)ms +825(input)ms +940(file.)ms +12 FB +395 2549 m +(Two)s +501(files)ms +602(are)ms +678(involved:)ms +882(the)ms +958(program)ms +1142(module)ms +1307(\()ms +11 FH +(PALINDROME.PAS)s +12 FB +(\))s +1740(and)ms +1827(a)ms +1864(test)ms +1949(file)ms +2030(\()ms +11 FH +(TEST-)s +11 FH +295 2489 m +(DATA.IN)s +12 FB +(\).)s +12 FAB +295 2306 m +(A.1. Specification)s +12 FB +295 2219 m +(A)s +343(palindrome)ms +583(is)ms +628(a)ms +663(sentence)ms +847(with)ms +948(the)ms +1021(property)ms +1203(that)ms +1290(the)ms +1364(letters)ms +1498(from)ms +1607(left)ms +1686(to)ms +1737(right,)ms +1856(read)ms +1955(the)ms +2028(same)ms +2143(as)ms +295 2159 m +(from)s +412(right)ms +527(to)ms +586(left.)ms +686(In)ms +748(the)ms +830(comparison)ms +1083(uppercase)ms +1304(and)ms +1396(lowercase)ms +1617(letters)ms +1759(are)ms +1841(considered)ms +2078(to)ms +2137(be)ms +295 2099 m +(equivalent)s +512(and)ms +593(all)ms +652(other)ms +763(characters)ms +975(are)ms +1044(simply)ms +1189(ignored.)ms +1364(Hence)ms +1500(an)ms +1556(empty)ms +1690(sentence)ms +1871(is)ms +1913(a)ms +1944(palindrome.)ms +295 2039 m +(Other)s +421(examples)ms +622(are:)ms +10 FH +395 1958 m +(\(************* #file "TESTDATA.IN" #comment off **************\))s +395 1916 m +(Ada)s +395 1875 m +(1234567)s +395 1833 m +(doremifasolosafimerod)s +395 1791 m +(\(******* Testdata #multiple *******\))s +395 1750 m +(\(***************** End of TESTDATA.PAS ************************\))s +12 FB +295 1657 m +(The)s +385(following)ms +592(sentences)ms +796(do)ms +858(not)ms +935(qualify)ms +1089(as)ms +1143(a)ms +1178(palindrome.)ms +10 FH +395 1576 m +(\(******* Testdata #quick *******\))s +395 1535 m +(Mr. Clinton won the elections over Mr. Bush.)s +395 1493 m +(This line is not palindromic.)s +395 1451 m +(Aabbccdd Aabbccdd Aabbccdd Aabbccdd)s +395 1410 m +(Abracadabra)s +395 1368 m +(supercalafragilisiticexpielecdosia)s +12 FB +295 1276 m +(The)s +385(following)ms +592(are)ms +665(examples)ms +867(of)ms +921(more)ms +1036(sophisticated)ms +1310(palindromes.)ms +10 FH +395 1195 m +(\(******* Testdata #quick *******\))s +395 1153 m +(Able was I, ere I saw Elba.)s +395 1111 m +(A man, a plan, a canal, Panama.)s +395 1070 m +(Norma is as selfless as I Am, Ron.)s +12 FB +295 977 m +(Note)s +404(that)ms +492(the)ms +565(famous)ms +725(Dutch)ms +860(sentence)ms +10 FH +395 896 m +(\(******* Testdata #quick *******\))s +395 855 m +(Koos Eekfeen keek maar door rood kerkraam, maar krek door rood raam)s +395 813 m +(keek neef Kees ook.)s +12 FB +295 721 m +(will)s +385(not)ms +461(be)ms +521(recognized)ms +753(as)ms +807(a)ms +842(plindrome)ms +1060(since)ms +1175(it)ms +1215(occupies)ms +1403(two)ms +1490(lines.)ms +395 661 m +(The)s +488(program)ms +11 FH +674(PALINDROME)ms +12 FB +965(reads)ms +1087(an)ms +1151(input)ms +1270(file,)ms +1365(filters)ms +1498(the)ms +1575(lines)ms +1686(that)ms +1777(are)ms +1854(palindromic)ms +2112(and)ms +295 601 m +(writes)s +429(them)ms +542(to)ms +593(an)ms +653(output)ms +793(file.)ms +8 FB +470 204 m +(The)s +530(CLiP)ms +608(Style)ms +685(of)ms +721(Literate)ms +833(Programming)ms +1025(\(3.091,)ms +1128(29-sep-93\))ms +12 FB +2075 204 m +( 1 )s +50 2 2130 216 li +50 2 2020 216 li +endpage +%%Page: 1 2 +begpage +12 FAB +295 3176 m +(A.2. Communication with the outside world)s +12 FB +295 3089 m +(The)s +391(program)ms +578(conforms)ms +785(to)ms +842(the)ms +922(general)ms +1087(template)ms +1278(of)ms +1338(a)ms +1378(Pascal)ms +1524(program.)ms +1724(We)ms +1812(introduce)ms +2019(the)ms +2098(files)ms +11 FH +295 3029 m +(IN_FILE)s +12 FB +501(and)ms +11 FH +586(OUT_FILE)ms +12 FB +820(to)ms +872(define)ms +1011(its)ms +1072(communication)ms +1396(with)ms +1499(the)ms +1573(outside)ms +1731(world.)ms +1874(The)ms +1966(actual)ms +2098(files)ms +295 2969 m +(have)s +401(to)ms +453(be)ms +513(specified)ms +706(at)ms +754(run-time.)ms +951(Thus)ms +1064(we)ms +1135(have)ms +10 FH +395 2888 m +(\(*************** #file "PALINDROME.PAS" ***********************\))s +395 2846 m +(\(****************************************************************\))s +395 2805 m +(\(* Program: Palindrome filter program. *\))s +395 2763 m +(\(* Purpose: To filter the palindromic lines from a given input *\))s +395 2721 m +(\(* file to a specified output file. *\))s +395 2680 m +(\(****************************************************************\))s +395 2638 m +(PROGRAM PALINDROME \(INPUT, OUTPUT, IN_FILE, OUT_FILE\);)s +395 2555 m +(\(******* Palindrome constants #multiple #comment off *******\))s +395 2513 m +(\(******* Palindrome types #multiple #comment off *******\))s +395 2471 m +(VAR)s +395 2430 m +( IN_FILE, OUT_FILE: TEXT;)s +395 2388 m +(\(******* Palindrome variables #multiple #comment off *******\))s +395 2305 m +(BEGIN)s +495 2263 m +(OPEN \(IN_FILE, 'TESTDATA.IN', HISTORY := OLD\); RESET \(IN_FILE\);)s +395 2221 m +( OPEN \(OUT_FILE, 'TESTDATA.OUT', HISTORY := NEW\); REWRITE)s +395 2180 m +(\(OUT_FILE\);)s +395 2096 m +( \(***************** Palindrome \(body\) **********************\))s +395 2055 m +( \(** Copy the lines of the IN_FILE that are palindromic to **\))s +395 2013 m +( \(** the OUT_FILE. **\))s +395 1971 m +( \(************************************************************\))s +395 1888 m +(END \(*PALINDROME*\).)s +395 1846 m +(\(******************* End of PALINDROME.PAS ********************\))s +12 FB +295 1754 m +(To)s +363(prepare)ms +525(the)ms +599(module)ms +761(for)ms +832(future)ms +964(declarations)ms +1218(of)ms +1272(constants)ms +1471(and)ms +1555(types)ms +1673(we)ms +1744(have)ms +10 FH +395 1673 m +(\(******* Palindrome constants #leader #quick *******\))s +395 1631 m +(CONST)s +395 1590 m +(\(******* Palindrome types #leader #quick *******\))s +395 1548 m +(TYPE)s +12 FAB +295 1436 m +(A.3. Processing of the files)s +12 FB +295 1349 m +(The)s +384(program)ms +565(processes)ms +11 FH +768(IN_FILE)ms +12 FB +972(line)ms +1059(by)ms +1120(line.)ms +1219(The)ms +1309(idea)ms +1403(is)ms +1448(to)ms +1499(buffer)ms +1632(an)ms +1691(exact)ms +1808(copy)ms +1917(of)ms +1970(the)ms +2043(current)ms +295 1289 m +(line)s +382(in)ms +11 FH +434(IN_LINE)ms +12 FB +(,)s +652(while)ms +776(at)ms +824(the)ms +898(same)ms +1014(time)ms +1116(its)ms +1176(letters)ms +1311(are)ms +1384(buffered)ms +1567(in)ms +11 FH +1618(LETTERS)ms +12 FB +(.)s +1836(So)ms +11 FH +1902(LETTERS)ms +12 FB +2107(will)ms +295 1229 m +(be)s +353(empty)ms +489(if)ms +531(the)ms +603(line)ms +689(holds)ms +808(no)ms +869(letters)ms +1003(at)ms +1050(all,)ms +1124(in)ms +1174(which)ms +1307(case)ms +1404(the)ms +1476(line)ms +1562(is)ms +1607(considered)ms +1835(to)ms +1885(be)ms +1943(palindromic)ms +295 1169 m +(by)s +357(definition.)ms +395 1109 m +(We)s +475(choose)ms +624(the)ms +696(buffers)ms +11 FH +848(IN_LINE)ms +12 FB +1051(and)ms +11 FH +1134(LETTERS)ms +12 FB +1337(to)ms +1387(be)ms +1445(of)ms +1497(the)ms +1569(same)ms +1682(type,)ms +11 FH +1792(TEXT_LINE)ms +12 FB +(,)s +2062(which)ms +295 1049 m +(we)s +365(will)ms +456(not)ms +532(specify)ms +689(in)ms +740(detail)ms +864(right)ms +971(now.)ms +1082(For)ms +1164(this)ms +1249(purpose)ms +1419(we)ms +1490(introduce)ms +1692(a)ms +1726(type)ms +11 FH +1825(ABSTRACT)ms +12 FB +(.)s +10 FH +395 968 m +(\(******* Palindrome types #quick *******\))s +395 926 m +( ABSTRACT = \(DEFINED, UNDEFINED\);)s +11 FH +295 834 m +(TEXT_LINE)s +12 FB +555(will)ms +646(temporarily)ms +892(be)ms +952(declared)ms +11 FH +1134(ABSTRACT)ms +12 FB +1367(and)ms +1453(its)ms +1513(details)ms +1656(will)ms +1747(be)ms +1807(defined)ms +1970(later.)ms +2084(Thus)ms +295 774 m +(the)s +368(declaration)ms +603(of)ms +11 FH +657(TEXT_LINE)ms +10 FH +395 693 m +(\(******* Palindrome types *******\))s +395 651 m +(\(******* Declaration of TEXT_LINE *******\))s +395 610 m +(\(***************** End of Palindrome types ********************\))s +12 FB +295 517 m +(is)s +340(temporarily)ms +586(satisfied)ms +765(with)ms +867(the)ms +940(type)ms +11 FH +1039(ABSTRACT)ms +12 FB +(.)s +10 FH +395 436 m +(\(******* Declaration of TEXT_LINE #quick #default *******\))s +395 395 m +( TEXT_LINE = ABSTRACT;)s +8 FB +470 204 m +(The)s +530(CLiP)ms +608(Style)ms +685(of)ms +721(Literate)ms +833(Programming)ms +1025(\(3.091,)ms +1128(29-sep-93\))ms +12 FB +2075 204 m +( 2 )s +50 2 2130 216 li +50 2 2020 216 li +endpage +%%Page: 2 3 +begpage +12 FB +295 3179 m +(The)s +385(declaration)ms +619(for)ms +690(the)ms +764(variables)ms +11 FH +957(IN_LINE)ms +12 FB +1162(and)ms +11 FH +1247(LETTERS)ms +12 FB +1452(becomes)ms +10 FH +395 3098 m +(\(******* Palindrome variables #quick *******\))s +395 3056 m +( IN_LINE,)s +395 3015 m +( LETTERS: TEXT_LINE;)s +12 FB +295 2922 m +(We)s +379(have)ms +488(to)ms +542(test)ms +11 FH +626(LETTERS)ms +12 FB +834(in)ms +887(order)ms +1008(to)ms +1062(decide)ms +1207(whether)ms +1383(or)ms +1439(not)ms +11 FH +1518(IN_LINE)ms +12 FB +1726(contains)ms +1907(a)ms +1944(palindrome.)ms +295 2862 m +(The)s +385(result)ms +508(of)ms +563(this)ms +647(test)ms +729(is)ms +775(flagged)ms +938(by)ms +11 FH +1000(IS_PALINDROME)ms +12 FB +(,)s +1383(for)ms +1453(which)ms +1588(we)ms +1659(introduce)ms +1860(the)ms +1934(declaration)ms +10 FH +395 2781 m +(\(******* Palindrome variables #quick *******\))s +395 2740 m +( IS_PALINDROME: BOOLEAN;)s +12 FB +295 2647 m +(Now)s +404(the)ms +478(body)ms +590(of)ms +644(the)ms +718(Palindrome)ms +961(filter)ms +1071(may)ms +1169(be)ms +1229(expanded)ms +1433(as)ms +10 FH +395 2566 m +( \(***************** Palindrome \(body\) **********************\))s +395 2525 m +( \(** Copy the lines of the IN_FILE that are palindromic to **\))s +395 2483 m +( \(** the OUT_FILE. **\))s +395 2441 m +( WHILE NOT EOF \(IN_FILE\) DO)s +395 2400 m +( BEGIN)s +395 2358 m +( \(***************** Palindrome \(1\) *********************\))s +395 2316 m +( \(** Read a line from IN_FILE into IN_LINE. The letters **\))s +395 2275 m +( \(** of this line are copied to LETTERS. **\))s +395 2233 m +( \(********************************************************\))s +395 2150 m +( READLN \(IN_FILE\);)s +395 2066 m +( \(***************** Palindrome \(2\) *********************\))s +395 2025 m +( \(** Test palindromicity of LETTERS. Set IS_PALINDROME **\))s +395 1983 m +( \(** to reflect the result of the test. **\))s +395 1941 m +( \(********************************************************\))s +395 1816 m +( IF IS_PALINDROME THEN)s +395 1775 m +( BEGIN)s +395 1733 m +( \(***************** Palindrome \(3\) *****************\))s +395 1691 m +( \(** Write IN_LINE to OUT_FILE. **\))s +395 1650 m +( \(****************************************************\))s +395 1566 m +( WRITELN \(OUT_FILE\);)s +395 1525 m +( END \(*IF*\);)s +395 1483 m +( END \(*WHILE*\);)s +395 1441 m +( \(************* End of Palindrome \(body\) *******************\))s +12 FAB +295 1329 m +(A.4. Choosing the structure of )s +11 FH +(IN_LINE)s +12 FAB +( and )s +11 FH +(LETTERS)s +12 FB +295 1242 m +(Before)s +442(we)ms +512(can)ms +593(proceed)ms +763(we)ms +833(need)ms +939(to)ms +989(establish)ms +1176(a)ms +1209(structure)ms +1396(for)ms +1466(the)ms +1538(objects)ms +11 FH +1692(IN_LINE)ms +12 FB +1896(and)ms +11 FH +1979(LETTERS)ms +12 FB +(.)s +295 1182 m +(Thus)s +412(we)ms +487(define)ms +11 FH +629(TEXT_LINE)ms +12 FB +894(as)ms +953(a)ms +993(structure)ms +1185(with)ms +1291(two)ms +1383(components.)ms +1654(The)ms +1749(first)ms +1847(component)ms +2087(is)ms +2137(an)ms +295 1122 m +(array,)s +11 FH +424(CHARS)ms +12 FB +(,)s +589(which)ms +726(contains)ms +907(the)ms +983(characters)ms +1200(to)ms +1254(be)ms +1315(buffered.)ms +1512(The)ms +1604(second)ms +1758(component,)ms +11 FH +2007(LENGTH)ms +12 FB +(,)s +295 1062 m +(indicates)s +484(which)ms +619(part)ms +709(of)ms +762(the)ms +836(array)ms +950(is)ms +996(actually)ms +1166(occupied.)ms +1371(The)ms +1461(maximum)ms +1676(number)ms +1841(of)ms +1895(characters)ms +2109(that)ms +295 1002 m +(can)s +375(be)ms +434(buffered)ms +614(by)ms +676(the)ms +748(structure)ms +934(is)ms +979(determined)ms +1215(by)ms +1277(the)ms +1349(length,)ms +11 FH +1498(MAX_L)ms +12 FB +(,)s +1659(of)ms +1712(the)ms +1784(array.)ms +11 FH +1911(MAX_L)ms +12 FB +2060(serves)ms +295 942 m +(as)s +349(an)ms +408(implementation)ms +735(parameter.)ms +10 FH +395 861 m +(\(******* Palindrome constants #quick *******\))s +395 820 m +( MAX_L = 132;)s +395 736 m +(\(******* Declaration of TEXT_LINE #quick *******\))s +395 695 m +( TEXT_LINE = RECORD)s +395 653 m +( CHARS: ARRAY[1..MAX_L] OF CHAR;)s +395 611 m +( LENGTH: 0..MAX_L;)s +395 570 m +( END \(*RECORD*\);)s +8 FB +470 204 m +(The)s +530(CLiP)ms +608(Style)ms +685(of)ms +721(Literate)ms +833(Programming)ms +1025(\(3.091,)ms +1128(29-sep-93\))ms +12 FB +2075 204 m +( 3 )s +50 2 2130 216 li +50 2 2020 216 li +endpage +%%Page: 3 4 +begpage +12 FAB +295 3176 m +(A.5. Reading a line)s +12 FB +295 3089 m +(For)s +383(efficiency)ms +601(reasons)ms +769(we)ms +846(fill)ms +11 FH +923(IN_LINE)ms +12 FB +1134(and)ms +11 FH +1225(LETTERS)ms +12 FB +1436(simultaneously.)ms +1770(Therefore)ms +1986(we)ms +2062(buffer)ms +295 3029 m +(every)s +418(character)ms +614(that)ms +701(is)ms +747(read)ms +846(from)ms +11 FH +955(IN_FILE)ms +12 FB +1160(in)ms +1212(the)ms +1285(variable)ms +11 FH +1459(IN_CHAR)ms +12 FB +(.)s +10 FH +395 2948 m +(\(******* Palindrome variables #quick *******\))s +395 2906 m +( IN_CHAR: CHAR;)s +12 FB +295 2814 m +(Only)s +404(when)ms +11 FH +522(IN_CHAR)ms +12 FB +724(turns)ms +834(out)ms +907(to)ms +956(be)ms +1013(a)ms +1045(letter)ms +1157(it)ms +1194(is)ms +1237(copied)ms +1380(to)ms +11 FH +1429(LETTERS)ms +12 FB +(.)s +1643(Since)ms +1764(this)ms +1846(process)ms +2006(is)ms +2049(crucial)ms +295 2754 m +(for)s +365(the)ms +439(overall)ms +590(operation,)ms +804(we)ms +875(make)ms +996(provisions)ms +1217(for)ms +1287(some)ms +1405(debugging)ms +1629(code)ms +1736(here.)ms +10 FH +395 2673 m +( \(***************** Palindrome \(1\) *********************\))s +395 2631 m +( \(** Read a line from IN_FILE into IN_LINE. The letters **\))s +395 2590 m +( \(** of this line are copied to LETTERS. **\))s +395 2548 m +( IN_LINE.LENGTH := 0;)s +395 2506 m +( LETTERS.LENGTH := 0;)s +395 2465 m +( WITH IN_LINE DO)s +395 2423 m +( WHILE NOT EOLN \(IN_FILE\) DO)s +395 2381 m +( BEGIN)s +395 2340 m +( READ \(IN_FILE, IN_CHAR\);)s +395 2298 m +( LENGTH := LENGTH + 1;)s +395 2256 m +( CHARS[LENGTH] := IN_CHAR;)s +395 2215 m +( IF IN_CHAR IN ['A'..'Z', 'a'..'z'] THEN)s +395 2173 m +( WITH LETTERS DO)s +395 2131 m +( BEGIN)s +395 2090 m +( LENGTH := LENGTH + 1;)s +395 2048 m +( CHARS[LENGTH] := IN_CHAR;)s +395 2006 m +( END \(*WITH/IF*\);)s +395 1965 m +( END \(*WHILE/WITH*\);)s +395 1881 m +( \(********************* Palindrome \(test\) **************\))s +395 1840 m +( \(** Check contents of IN_LINE and LETTERS. #optional **\))s +395 1798 m +( \(********************************************************\))s +395 1715 m +( \(***************** End of Palindrome \(1\) **************\))s +12 FAB +295 1602 m +(A.6. Testing for palindromicity)s +12 FB +295 1516 m +(We)s +387(test)ms +479(the)ms +563(palindromicity)ms +881(of)ms +11 FH +945(LETTERS)ms +12 FB +1161(in)ms +1223(two)ms +1321(steps.)ms +1456(First)ms +1571(we)ms +1652(transform)ms +1869(the)ms +1953(contents)ms +2143(of)ms +11 FH +295 1456 m +(LETTERS)s +12 FB +503(to)ms +558(uppercase)ms +774(and)ms +863(then)ms +965(we)ms +1039(compare)ms +1227(the)ms +1305(characters)ms +1523(of)ms +11 FH +1581(LETTERS)ms +12 FB +1790(pairwise.)ms +1988(The)ms +2082(com-)ms +295 1396 m +(parison)s +455(is)ms +502(done)ms +612(starting)ms +775(with)ms +878(the)ms +952(most)ms +1063(outside)ms +1220(characters)ms +1436(and)ms +1522(progressing)ms +1768(inward.)ms +1933(The)ms +2024(string)ms +2151(is)ms +295 1336 m +(assumed)s +480(a)ms +516(palindrome)ms +757(until)ms +862(the)ms +937(opposite)ms +1120(is)ms +1167(proven)ms +1319(through)ms +1488(a)ms +1524(pair)ms +1615(of)ms +1670(different)ms +1856(characters.)ms +2085(With)ms +295 1276 m +(the)s +368(local)ms +478(counter)ms +10 FH +395 1195 m +(\(******* Palindrome variables #quick *******\))s +395 1153 m +( I: INTEGER;)s +12 FB +295 1061 m +(we)s +365(keep)ms +472(track)ms +585(of)ms +639(the)ms +712(comparing)ms +939(process.)ms +1114(Now)ms +11 FH +1223(Palindrome \(2\))ms +12 FB +1621(can)ms +1703(be)ms +1763(expanded)ms +1967(as)ms +10 FH +395 980 m +( \(***************** Palindrome \(2\) *********************\))s +395 938 m +( \(** Test palindromicity of LETTERS. Set IS_PALINDROME **\))s +395 896 m +( \(** to reflect the result of the test. **\))s +395 855 m +( WITH LETTERS DO)s +395 813 m +( BEGIN)s +395 771 m +( \(* Transform lowercase to uppercase. *\))s +395 730 m +( FOR I := 1 TO LENGTH DO)s +395 688 m +( IF CHARS[I] IN ['a'..'z'])s +395 646 m +( THEN CHARS[I] :=)s +395 605 m +( CHR\(ORD\(CHARS[I]\) - ORD\('a'\) + ORD\('A'\)\);)s +8 FB +470 204 m +(The)s +530(CLiP)ms +608(Style)ms +685(of)ms +721(Literate)ms +833(Programming)ms +1025(\(3.091,)ms +1128(29-sep-93\))ms +12 FB +2075 204 m +( 4 )s +50 2 2130 216 li +50 2 2020 216 li +endpage +%%Page: 4 5 +begpage +10 FH +395 3188 m +( \(* Perform the palindromicity test. *\))s +395 3146 m +( IS_PALINDROME := TRUE;)s +395 3105 m +( I := 1;)s +395 3063 m +( WHILE IS_PALINDROME AND \(I <= LENGTH DIV 2\) DO)s +395 3021 m +( IF CHARS[I] = CHARS[LENGTH-I+1] THEN)s +395 2980 m +( I := I + 1)s +395 2938 m +( ELSE)s +395 2896 m +( IS_PALINDROME := FALSE;)s +395 2855 m +( END \(*WITH*\);)s +395 2813 m +( \(***************** End of Palindrome \(2\) **************\))s +12 FAB +295 2701 m +(A.7. Writing the palindrome)s +12 FB +295 2614 m +(The)s +385(only)ms +486(remaining)ms +701(action)ms +836(is)ms +882(to)ms +933(write)ms +1049(the)ms +1122(contents)ms +1301(of)ms +11 FH +1356(IN_LINE)ms +12 FB +(.)s +1573(Again)ms +1708(we)ms +1779(need)ms +1885(a)ms +1920(local)ms +2030(counter)ms +10 FH +395 2533 m +(\(******* Palindrome variables #quick *******\))s +395 2491 m +( J: INTEGER;)s +12 FB +295 2399 m +(The)s +385(writing)ms +542(proceeds)ms +732(straight)ms +894(forward.)ms +10 FH +395 2318 m +( \(***************** Palindrome \(3\) *****************\))s +395 2276 m +( \(** Write IN_LINE to OUT_FILE. **\))s +395 2235 m +( WITH IN_LINE DO)s +395 2193 m +( BEGIN)s +395 2151 m +( FOR J := 1 TO LENGTH DO)s +395 2110 m +( WRITE \(OUT_FILE, CHARS[J]\);)s +395 2068 m +( END \(*WITH*\);)s +395 2026 m +( \(************* End of Palindrome \(3\) **************\))s +8 FB +470 204 m +(The)s +530(CLiP)ms +608(Style)ms +685(of)ms +721(Literate)ms +833(Programming)ms +1025(\(3.091,)ms +1128(29-sep-93\))ms +12 FB +2075 204 m +( 5 )s +50 2 2130 216 li +50 2 2020 216 li +endpage +%%Trailer +enddocument +%%Pages: 5 +%%DocumentFonts: +%%+ Helvetica-Bold +%%+ Times-Roman +%%+ Courier +%%EOF +
\ No newline at end of file |