IO.mesaTop-levelstreamandI/OinterfaceforCedarLasteditedby:TeitelmanonJanuary12,19833:01pmNote:thisinterfaceisheavilystructuredusingTiogaNodes.Thus,youcanusethelevelclippingtoobtainatableofcontents,andtosuccessivelyrefinedlevelsofdetailintheareasyouareespeciallyinterested.DIRECTORYAsciiUSING[CR,SP,TAB,LF,BS,ControlA,ControlX,FF,NUL,ESC,DEL,BEL],AtomUSING[PropList],RopeUSING[ROPE],RTBasicUSING[TV,Type],SystemUSING[GreenwichMeanTime],TimeUSING[Current];IO:CEDARDEFINITIONSIMPORTSTime=BEGINTypesSTREAM:TYPE=REFSTREAMRecord;STREAMRecord:TYPE=RECORD[streamProcs:REFStreamProcs,--seebelowstreamData:REFANY,--dataprivatetostreamProcspropList:Atom.PropList_NIL,--permitsassociatingarbitraryinformationwithstream.seeStoreData,LookupData,andRemoveDatabelow.backingStream:STREAM_NIL--forusewithlayeredstreams.];Handle:TYPE=STREAM;--forbackwardcompatibilityROPE:TYPE=Rope.ROPE;TV:TYPE=RTBasic.TV;Type:TYPE=RTBasic.Type;Base:TYPE=[2..36];GreenwichMeanTime:TYPE=System.GreenwichMeanTime;CreatingStreamsThefollowingproceduresenabletheusertocreateinputand/oroutputstreamstovariousentitiessuchasviewers,files,ropes,aswellasstreamsthatarelayeredontopofanotherstream,thebackingstream,soastomodifyoraugmentthebehaviourofthebackingstream,suchaseditedstreams,dribblestreams,filteredcommentstreams,etc.Allofthesestreamsaredefinedintermsofageneralmechanismforimplementingstreams,CreateProcsStream,whichisdescribedbelowunderthesectionDefiningNewStreams.CreateViewerStreams:PROC[name:ROPE]RETURNS[in:STREAM,out:STREAM];createsanewviewerwithindicatedname,andreturnstwostreams"connected"tothatviewer,oneforinputandoneforoutput.Theinputstreamisaneditedstream.NotethatViewerIO.CreateViewerStreams...p aq ^= ! \! !H#&) Y& #'+0X4T719<|?BmG WW6 '],B02267:_>@CZ VU rs St QYsoQYUQYtQYsQYtQYs}QYQYtQYsQYYQYtQYsQY{QYt4QYsQYQYtiQY FQY&s-2QY-QYt.QYs/QY0iQYt2QYs2QY3QYt5QYs5QY6QYt8CE L TW _t- s-w-t -s--r!-!-"$' *.t+v *OtK*OsI*O*Ot*Os*O$*OtO*OrM*O*O% u (t!(s((tu([(s((t(u &t &s&9&t&&s&&t&v %Rt%Rs%R%RtA%R&%R v #t#s##t*##v !t!s!~!t!!p wq   L #%[)`- 16+;"<AF]  &j#\&)(z-K/P13z8=J?D :  BG1#%E',1d46':H?DB  5!%A*^,2379:?GR  I$(*W049 ;@VFE Dv tsntSs!"t%s%&t+,<s.c/t3.4 s67t;<&r H#f'b*.1)6 =?OB!F  0 }#@&+",.2o7%:x TVm$enablescreatingstreamsthatareconnectedtoanexistingviewer,orspecifyingthattheinputstreamisnotaneditedstream,e.g.sothattheclientcanthenspecifyhisowndeliverWhenprocedurewhencreatinganeditedstreamontopoftheinputstream.CreateFileStreamTocreateastreamforreading/writingonafileuseFileIO.Open.CreateMessageWindowStreamTocreateastreamforwritingtotheMessageWindow,useViewerIO.CreateMessageWindowStream.CreateInputStreamFromRope,RIS:PROC[rope:ROPE,oldStream:STREAM_NIL]RETURNS[stream:STREAM];streamgetscharsfromuser'srope.IfoldStreamisnon-NIL,itisreusedratherthanallocatingspaceforanewstream.CreateOutputStreamToRope,ROS:PROCRETURNS[stream:STREAM];streamputscharsintoaropewhichcanberetrievedviaGetOutputStreamRope,describedbelow.Finepoint...inordertoperformthisoperationefficiently,aREFTEXTisobtainedfromapoolofscratchREFTEXTs.Asaresult,itisagoodideatoclosethestreamwhenitisnolongergoingtobeusedinordertoreturnthescratchstructuretoacommonpool.However,ifyoudonot,e.g.ifanerroroccurs,allthatwillhappenisthatthestructurewillbegarbagecollectedwhenitisnolongerreferenced,andnewscratchstructurewillbeallocatedtotakeitsplaceinthepool.CreateInputStreamFromText:PROC[text:REFREADONLYTEXT,oldStream:STREAM_NIL]RETURNS[stream:STREAM];streamgetscharsfromuser'sREFTEXT.IfoldStreamisnon-NIL,itisreusedratherthanallocatingspaceforanewstream.CreateOutputStreamToText:PROC[text:REFTEXT,oldStream:STREAM_NIL]RETURNS[stream:STREAM];streamputscharactersintotext.IfoldHisnon-NIL,itisreusedratherthanallocatingspaceforanewstream.CreateEditedStream:PROCEDURE[in:STREAM,echoTo:STREAM,deliverWhen:DeliverWhenProc_IsACR]RETURNS[stream:STREAM];createsalayeredinputstreamontopofinwhichbuffersinputcharactersandallowstheusertoperformcharactereditingwith^A,^W,^Q.TypingaDELwillcauseCreateEditedStreamtoraiseIO.Signal[Rubout].Defaultistobuffertocarriagereturn.InputcharactersareechoedtoanderasedfromechoTo.ChangeDeliverWhencanbeusedtochangebufferingcondition.DeliverWhenProc:TYPE=PROC[char:CHAR,stream:STREAM]RETURNS[BOOL];IsACR:DeliverWhenProc;--returnsTRUEforCR.ChangeDeliverWhen:PROC[self:STREAM,proc:DeliverWhenProc]RETURNS[oldProc:DeliverWhenProc];currentlyimplementedbyEditedStreamandViewerEditedStream(SeeViewerIO).GetBufferContents:PROC[self:STREAM]RETURNS[buffer:ROPE];returnscontentsofthebufferwithoutdisturbing.ForuseinconjunctionwithDeliverWhenProcswhichmightneedtoseewhathasbeentypedinordertodecidewhethertoterminate,e.g.parenthesisbalancing,etc.CurrentlyimplementedbyEditedStreamandViewerEditedStream.CreateDribbleStream:PROCEDURE[stream:STREAM,dribbleTo:STREAM,flushEveryNChars:INT_-1]RETURNS[s:STREAM];createsalayeredstream,s,ontopofstream,suchthatcharactersreadfrom/printedtoswillbe2r b&!$*W+-27{94 ?lB>D`Q #&8'*-03K6V:<? ^!%*,.Y/2H5x [r[[ N"$.l0_136H x X/rX/X/ $%*W,~125 ? V#v TtTulT7Tt QTs!OT!Tt$T%?Ts(T)Tt+T,T s3T4Tt9Ts:T;TtpTtCTCTs S7tS7S7rQm1#!$+),245}9=@ Ov Lt Ls!L"L%t+vL+Ls0L1bLt5L5LrJmS#&X((-/>CI@ GN$ +,L/35M:=?2B+CEDdj "#r$'*,u/26q9;K<>BFDHx #'-F.058>@$BDBr #m&*,.1769m;<@RE@J #;&*0A24:X;?@D]F?Rv ;tN;sL;;t!;"<;s%m;&A;(/t2;2; s: ;:;t?@;s@;A;tB;s :Vt:V$:Vs:V:Vt:V;:Vr8m1#')@/1&7K8:>>BC7 v 3t3s33t!m3!3s%3%3't*3+3 s233>3t73s9`3:I3t;l3s v tscts !t$ $ls'(t+N,*s11t5s67tv tr !0".&+5-]v utOusMuut u!=us$Au$ut) u)u-s9u9ut?u?gur1$ !%*-816:= v ztRzsOzztz ?zs#Cz#zt( zs(z)zt.|z.zs3z4[zt6z6zr1 #( /s24h6 =X)i"L&')O*-30|269;V>@ " ) 0 39) AB^#*v t s 6 t!- ! s&z ' t+D , s3 3 t7 8 sD E tG s  t 6 s W t  r 5i s"$l)",?/ 58 @B*C2Ey) bTVm$readfrom/printedtostream,andalsooutputtodribbleTo.IfflushEveryNCharsis>0,willautomaticallycallFlushondribbleToeverynChars.CreateBufferedOutputStream:PROC[stream:STREAM,deliverWhen:DeliverWhenProc_IsACR,bufferSize:NAT_256]RETURNS[s:STREAM];createsanoutputstreamontopofstreamsuchthatcharactersarebuffereduntil(a)thebufferSizeisexceeded,or(b)deliverWhen[char]isTRUE,or(c)anexplicitFlushisperformed,atwhichpointthecharactersareoutputtostreamusingPutBlock.CreateFilterCommentsStream:PROCEDURE[stream:IO.STREAM]RETURNS[s:STREAM];createsainputstreamontopofstreamsuchthatanycommentsarefilteredout,i.e.thecharacterscomprisingthecommentsarenotreturnedbyGetChar[s].Acommentconsistsofthatsequenceofcharactersbeginningwith--andendingwith--oraCR.Inthelattercase,theCRisnotconsideredtobepartofthecomment.AppendStreams:PROC[in:STREAM,from:STREAM,appendToSource:BOOL_TRUE];modifies`in'sothatanattempttoreadcharactersfrom`in'willcausethecharacterstobeobtainedfrom`from'until`from'runsdry,atwhichpoint`in'isreturnedtoitspreviousstate.Notethatitispermissibletonest,i.e.concatenate,morethanonestreaminthisfashion.IfappendToSource=TRUEthenmodificationisdonetotherootstream,i.e.descendsthroughnon-NILbackingstreams.Forexample,ifinisaneditedstream,thenthiswillcausecharacterstobeinsertedintobuffer,fromwhichtheycanbebackspacedover,exactlyasthoughtheyhadbeentyped,ratherthandeliveredtotheclientimmediately.IfinisadribbleStream,thenthecharacterswillbedribbledetc.noWhereStream:STREAM;outputstreamthatsimplydiscardsitscharacters.Unformattedstreamprocedures:GetChar,PutChar,Close,etc.Note:Notallofthefollowingareimplementedforallstreams,e.g.GetLengthisnotimplemented(doesnotmakesense)forakeyboardstream.Ifanoperationisinvokedthatisnotimplemented,theError[NotImplementedForThisStream]israised.However,manyoperationsaredefaultedevenwhentheyarenotimplemented.Seediscussionbelowofexactlywhichoperationsareimplementedforwhichstreams.)InputProcedures:GetChar,EndOf,CharsAvail,GetBlock,Backup,PeekChar,SetEcho,...GetChar:PROC[self:STREAM]RETURNS[CHAR]=INLINE{RETURN[self.streamProcs.getChar[self]]};EndOf:PROC[self:STREAM]RETURNS[BOOL]=INLINE{RETURN[self.streamProcs.endOf[self]]};trueifreadingfromthisstreamwouldraiseanendofstreamerror.CharsAvail:PROC[self:STREAM]RETURNS[BOOL]=INLINE{RETURN[self.streamProcs.charsAvail[self]]};trueifself.GetChar[]wouldreturnacharacterwithoutwaiting.Note:...Formoststreams,EndOfisequivalentto~CharsAvail,andinfact,ifCharsAvailisnotspecified,adefaultprocedureissuppliedwhichwillreturnsasitsvalueNOTEndOf.However,notethatEndOfisalwaysFALSEforakeyboardstream,i.e.itisalwaysoktotrytoreadfromakeyboardstream,evenwhenCharsAvailisFALSE,i.e.therearenomorecharactersavailablenow.GetBlock:PROC[self:STREAM,block:REFTEXT,startIndex:NAT_0,stopIndexPlusOne:NAT_3rb&  A"%)+ 13>@&A[B` D%) v ]0tp]0sn]0]0t!]0"^]0s'H]0']0t,]0,]0 5@BC [ s[[t[N[sF[[t!7[![s#[#[t'[(J[rY!e# 'g*-V 36;R>@B X9MX8%g&+-T/f1Y6$9;Q BCVX g!#K'+Av SCtSCsSCVSCt&MSC&SCs+SC,SCt,SCs-7SCt2SCs2SC3SCt8SC9=SCs:SC;^SCt?SC?SCrQD!%) +.t47;>_@B O J #(`*: 1o28=?GBGNM Q"&)+l-%.Z1135[8<9>ABqL qcv IV t5IVs2IVIVtIV"IVsIIVIVt!IV!IVs%IV&pIVt*IV+wIVs6IV7EIVt:!IVs;IVIV?=IVrG^m?2!"% ,1/o14Z8:R @BfFT"%(b*-1a35#:<'>CFD`4^  U#% -i036:<?B  ,#7 *,`/1C36i;=RBA}!&()+.-!158;i=A ?jVZ!g!%(z+, 370;=BE= "$]&*X 2635j68 AD< Qv 8 t8s8?8tj8r7%M}"$ p 3  q!3"3'-1 / z(| ')B+&0h29;6= E .  %1$&{(/:069;k>3 G/ ,d"!v"'-,0 7w9?BF * {,  !%',1 7:z CE )v % q%H%'  'y-3=9?v #t#s##t3##s#9#td#sL# #t##s$6#t'#!]s!]]!]tt!]s%!]t !]p!]!v tstbset0st#s#kt&s]tts%t prg5 I!@%,(g*[ 1v  ttsqtsts t%s&t),s]tts%t p$rp5 "$ ).!9x ! ') 14669=: ACz m"$)<-/4K67;k>!"&,.,/`529<=s>C8E3F+$'++ 2239;I>A B bv 5t 5s 5G 5t 5% 5s) 5 5t 5 5s# 5# 5%t( 5) 5 s0 51o 5t3e 54 56sBY 5CB 5tE8 5y) TVm$LAST[NAT]]RETURNS[nBytesRead:NAT]=INLINE{RETURN[self.streamProcs.getBlock[self,block,startIndex,stopIndexPlusOne]]};valueisnumberofcharactersactuallyreturned.Equivalentto,butmoreefficientthan,ncallstogetChar...forthosestreamsthatprovideanimplementationforgetBlock,e.g.filestreams.Otherwise,thegetBlockisexactlythesameas,i.e.isaccomplishedby,performingncallstoGetChar.Seediscussionofdefaultproceduresbelow.UnsafeGetBlock:UNSAFEPROC[self:STREAM,block:UnsafeBlock]RETURNS[nBytesRead:INT]=UNCHECKEDINLINE{RETURN[self.streamProcs.unsafeGetBlock[self,block]]};valueisnumberofcharactersactuallyreturned.ThetypeUnsafeBlock...isdefinedbelowinthesection"PrivateandSemi-privatetypes."Backup:PROC[self:STREAM,char:CHAR];Usedwheninputwenttoofar...NotethatBackupisanoperationontheinputstream.ItmodifiesselfsothatthenextgetChar[self]willreturnthesamecharacterandleaveselfinthestateitwasinbeforetheBackup.TheimplementorisonlyrequiredtoimplementBackupforthosesituationswherecharisinfactthecharacterthatwaslastreadbygetChar.(Thecharacterargumentisrequiredinordertoprovideagenericimplementationfortheoperation,i.e.whentheparticularstreamdoesnotimplementBackupitself).PeekChar:PROC[self:STREAM]RETURNS[char:CHAR];doesaGetCharfollowedbyaBackup,i.e.effectivelylooksatthenextcharacterwithoutactuallyreadingit.SetEcho:PROC[self:STREAM,echoTo:STREAM]RETURNS[oldEcho:STREAM];causeseverycharacterreadfromstreamtobeechoedtoechoToifnon-NIL.Outputprocedures:PutChar,PutBlock,Flush,EraseChar,GetOutputStreamRope,...PutChar:PROC[self:STREAM,char:CHAR]=INLINE{self.streamProcs.putChar[self,char]};PutBlock:PROC[self:STREAM,block:REFREADONLYTEXT,startIndex:NAT_0,stopIndexPlusOne:NAT_LAST[NAT]]=INLINE{self.streamProcs.putBlock[self,block,startIndex,stopIndexPlusOne]};UnsafePutBlock:PROC[self:STREAM,block:UnsafeBlock]=INLINE{self.streamProcs.unsafePutBlock[self,block]};Flush:PROC[self:STREAM]=INLINE{self.streamProcs.flush[self]};causescharactersthathavebeenoutputtostream,butnotyetsent,e.g.becauseofbuffering,tobesentEraseChar:PROC[self:STREAM,char:CHAR];erasescharfromoutputstream,e.g.erasesthebitsfromthedisplay...NotethatEraseChar,isanoperationontheoutputstream.WhateverthecorrespondinginputstreammighthavedoneaboutthecharacterthatisbeingerasedisanentirelyseparateoperationEraseCharjustspecifieswhatistobedonetotheoutputstream.CurrentPosition:PROC[self:STREAM]RETURNS[position:INT];numberofcharactersoutputsincelastCR.NewLine:PROC[self:STREAM]=INLINE{IFself.CurrentPosition[]#0THENself.PutChar['\n]};outputsaCRunlessalreadyatbeginningoftheline.SpaceTo:PROC[self:STREAM,n:INT,nextLine:BOOLEAN_TRUE];spacestopositionn.IfcurrentpositionalreadybeyondnandnextLineisTRUE,thennewlineandnspaces.GetOutputStreamRope:PROC[self:STREAM]RETURNS[ROPE];usedinconjuctionwiththeCreateOutputStreamToRopetogettheresultingrope4s b&tb&sb&tb&b&sb&b&t_b&b& s!b&"b&t$Gb&`ys`y]`ytt`ys%`yt `yp`y,0 7r^ %* 1359T>{AC6FP]% [xL/"$ .$0L6M8;!@[ GY"f$w&( 0J2| 9[:=?]E1X) Ac $v T tTsTTtTdTs"hT#Tt'2T(T,H s4T5Tt:@T:T sBTCTtDTS%sS%S%tgS%sS%t"S%"cS%%8rQx %*-0t O+w"(R* 2v NtmNskNNtN[Ns_NNt)NNs!N"YNt$N%JNrLqv{ JsE;$&(,S1 2t7J8mJr:sJ:J<,>AJtI rII!%T+?-t1KI1Ir3I49I5|7:@DGuA "0%,*o,279=? CNEo!$'m),.4^7=CD&6d !"' 13A5 ;>AB } 'p,fv @t@s@s@t@R@sU@@t @s@@t$@%[@s(@)@t,=@,@r?%G %n' -1x35i8~>iCB=~v ;t;s;;t;;s;#;tN;*;s#;$,;t(X;s)?;*;t/0;/;s5{;6;t:E;:;r:$>!&H').//45v 6 q66"&H -N< v 4t4s44t44s4#4tN4+4s!4"4t% 42Ws2W]2Wtt2W%2W''v 0t0s010t00s00t00s"0#0%,t/000 s7r08Z0t:P0;0 /s//t/s//t/s ^/t"/#6/-Vs-V]-Vtt-V%-V'+ 2}v + t+s+R+t+1+s5++t!+"+' )s)])tt)%)%+vv (OtC(Os@(O(Ot(O0(Os4(O(Ot(O&s&]&tt&%&r$> !&',j.1/3c69>? EGe#Nv !t1!s/!!tR!!s!X!t!_!s"!#!t&A!&!rT!I#'* ,/2#  GsE W &(t*G+Gr/^G/G4:,BD v t s a tF  s! "L t&w s'_ (2 t-P s- t0 1' r ; PL/1z36;y) TVm$MiscellaneousProcedures:Reset,Close,UserAbort,GetIndex,SetIndex,GetLength,SetLengthReset:PROC[self:STREAM]=INLINE{self.streamProcs.reset[self]};restoresthestreamtoacleanstate,e.g.mayflushorrestoreinternalbuffers.typicallyinvokedfollowinganerror,Close:PROC[self:STREAM,abort:BOOL_FALSE]=INLINE{self.streamProcs.close[self,abort]};UserAbort:PROC[stream:STREAM]RETURNS[abort:BOOLEAN];Ifunimplementedforcorrespondingstreamorbackingstream,returnsFALSE.TRUEmeansuserindicateddesiretoabortoperation.Itisuptoprogramtotaketheappropriatesteps,whichshouldculminateinraisingIO.UserAborted.CurrentlyimplementedforViewerStreams,TRUEifusertypescontrol-Deltotheviewer,oriftheviewerisconnectedauserexec,canalsobesetbyclickingSTOP.SetUserAbort:PROC[stream:STREAM];setstheuserabort,i.e.providesaprogrammablewaytoabort(theoperationcurrentlyrunningin)anexec.Generatesanerrorifnotimplementedforthecorrespondingstream.CurrentlyonlyimplementedforViewerStreams.ResetUserAbort:PROC[stream:STREAM];turntheabortbitoff,ifimplemented.Otherwise,nop.GetIndex:PROC[self:STREAM]RETURNS[index:INT]=INLINE{RETURN[self.streamProcs.getIndex[self]]};SetIndex:PROC[self:STREAM,index:INT]=INLINE{self.streamProcs.setIndex[self,index]};GetLength:PROC[self:STREAM]RETURNS[length:INT];SetLength:PROC[self:STREAM,length:INT];Formattedstreamprocedures:Put,PutF,PutList,PutRope,PutTV,PutType,...Put:PROC[stream:STREAM,v1,v2,v3:Value_[null[]]];Thebasicoutputroutine,handlesanytypeviaValues,definedlater.Providesconvenientdefaultbehaviourforsimpleoutput,i.e.outputsintegersandcardinalsindecimal,timeusingbothdateandtime,etc.Example:s.Put[int[x+y],rope["isgreaterthan"],int[x]]wouldproduce'8isgreaterthan5',forx=5andy=3.Formorecontrolovertheoutput...usePutF,describedbelow,whichallowsspecificationoffieldWidth,base,etc.Putonlytakesthreevaluearguments...sothattheprocedurecallcanbe"fast"(i.e.take11orfewerwordsonthestack).PutListcanbeusedforcallsspecifyingmoreargumentsattheexpenseoftheallocationofspacefortheLIST,ortheusercanwriteseveralcallstoPut.PutF:PROC[stream:STREAM,format:ROPE_NIL,v1,v2,v3,v4,v5:Value_[null[]]];producesoutputaccordingtoacollectionofvaluesandaformatcontrolstringwhichcanincludeembeddedformatcodes.Forexample:s.PutF["%disgreaterthan%d",int[x+y],int[x]]isequivalenttotheabovecallonPut.Formorediscussion,seesection"PFPackage".format=NILisequivalentto"%g%g%g..."whichmeanstoprinteachvaluethesameaswouldbeprintedbyPut.NotethatPutFisaslowprocedurecall,i.e.itsargumentsrequiremorethan11wordsonthestack.PutFmayraisesignals.RESUMEwillalwaysworkandwilleitherdonothingorprint"#####".PutList,PutL:PROC[stream:STREAM,list:LISTOFValue];foroutputtingmorethanthreequantitiesviaasinglecalltoPut.PutFList,PutFL:PROC[stream:STREAM,format:ROPE_NIL,list:LISTOFValue];PutFToRope,PutFR:PROC[format:ROPE_NIL,v1,v2,v3,v4,v5:Value_[null[]]]RETURNS[r:ROPE]5v b&  qub&~b&" )0d6 =v _dtN_dsL_d_dto_d_ds_du_dt_d]s]]]tt]%]r\FI~ #&),[.2{7R)w #%&(*/146 >AP'Yr)/ 79 CWGN/ P A$&v'*.</57<?|BIDF,M3v K t!KsKKtKKsKKt"K#&KrI!#"W +0-/3!5;AFH<Hv!(# +b-/ 8o=&C?F  v D twDsuDDtDeDsNDDt$D%DrCFNK $ +vv AtAs}A%AtAAsAAtAsAAt$A% As)QA)At+]A?s?]?tt?s%?t ?p?"v >OtI>OsF>O>Oti>O>Os>Oo>Ot>Ow>Os">O#%>Ot$>O<s<]<tt<%<'<v ;t\;sZ;;t};;s;;t;s; j;t%;%;s*;+;t,;- ;v 9Yt%9Ys#9Y9YtF9Y9Ys9YL9Ytw9YT9Ys$9Y$q9Yt&9Y&u9Yp 56N q 56 56"&+16<v 1t1s11t11s11t11"$p(g) r0@9xs"U$'*.3z6VAD,h' +-,1-4M6H:o>[ChD+Juz!"$&F(,E036) $( 0q259<'.#  &S""F$(*-/1_48:=AdFG$ !L$+@,/14@580 >i@ CE#!& !&g)+&v !]t!]s!]!]t!]!]s!]l!]t!]t!]s#h!]$AC"tzy"D"r!"""$e(,&.1_5-zv tlvI0tLsJt:s$t"#s&':)ft+f,cr+6 !A &)*:.02Mv tI v%  t s  t  s | t$ % s*x +L t- s/ 0h t1 2h s5 5 8t: ; v t v x t s , t t s"i #< t% s'p (Y t)| *X ,.13M59;0s? @ tE FL s 5t 5y) TVm$=INLINE{stream:STREAM_CreateOutputStreamToRope[];stream.PutF[format,v1,v2,v3,v4,v5];r_stream.GetOutputStreamRope[];stream.Close[];};PutText:PROC[self:STREAM,t:REFREADONLYTEXT]=INLINE{self.PutBlock[t]};muchmoreefficientthanself.Put[text[t]];PutRope:PROC[self:STREAM,r:ROPE];muchmoreefficientthanself.Put[rope[r]];PutTV:PROCEDURE[stream:STREAM,tv:TV,depth:INT_4,width:INT_32,verbose:BOOL_FALSE];depthandwidthcontrolthecutoffforprintingofthetv,verbosespecifieswhethertoprintadditionalinformation,e.g.theoctalvalueforglobalframes,etc.stream.Put[tv[x]]isequivalenttostream.PutTV[x],andistheproperwaytoprinttvsformostapplications..PutType:PROC[stream:STREAM,type:Type,depth:INT_4,width:INT_32,verbose:BOOLEAN_FALSE];IfverboseisFALSE,justthenameofthetypeisprinted.IfverboseisTRUE,theundertypeisalsoprintedfornamedtypes.Forexample,ifxisoftypeBreakProc,thenstream.PutType[x,FALSE]prints:IO.BreakProc,whereasstream.PutType[x,TRUE]printsas:IO.BreakProc=PROC[c:CHAR]RETURNS[IO.BreakAction].Inaddition,therangetypeisprintedforundertypesthatarerefsorpointers.Forexample,ifxisoftypeSTREAM,stream.PutType[x,TRUE]printsas:IO.STREAM=REFIO.STREAMRecord;(andonthenextline)IO.STREAMRecord:TYPE=RECORD[...];stream.Put[type[x]]isequivalenttostream.PutType[type]PutSignal:PROC[stream:IO.STREAM,signalTV,argsTV:TV_NIL];Printstheindicatedsignalonstream.IfsignalTV=NIL,printsthe"current"signal,i.e.foruseinsideofacatchphrase.ProceduresforconstructingValues:atom,bool,card,char,int,real,refAny,rope,tv,...saveswritingtwoextrabrackets.thetypeValueisdefinedinsection4.atom:PROC[v:ATOM]RETURNS[Value]=INLINE{RETURN[[atom[v]]]};bool:PROC[v:BOOL]RETURNS[Value]=INLINE{RETURN[[boolean[v]]]};card:PROC[v:LONGCARDINAL]RETURNS[Value]=INLINE{RETURN[[cardinal[v]]]};char:PROC[v:CHAR]RETURNS[Value]=INLINE{RETURN[[character[v]]]};int:PROC[v:INT]RETURNS[Value]=INLINE{RETURN[[integer[v]]]};real:PROC[v:REAL]RETURNS[Value]=INLINE{RETURN[[real[v]]]};refAny:PROC[v:REFREADONLYANY]RETURNS[Value]=INLINE{RETURN[[refAny[v]]]};rope:PROC[v:ROPE]RETURNS[Value]=INLINE{RETURN[[rope[v]]]};string:PROC[v:LONGSTRING]RETURNS[Value]=INLINE{RETURN[[string[v]]]};text:PROC[v:REFREADONLYTEXT]RETURNS[Value]=INLINE{RETURN[[text[v]]]};time:PROC[v:GreenwichMeanTime_Time.Current[]]RETURNS[Value]6tbfsbf]bft`s`H`t`i`-V9;>:@wBEvF~_"]^v [t[s[[tq[[s[w[t[[s[ [")t,[YsY]YttY%YrXM'Nnv Vt(Vs&VVtVVsVVtVVs BV!Vt#SV#VrT'Nnv S=tS=sS=S=t2S=S=sS=S=t"IS=#&S=s%BS=%S=t&S='S=s, S=,tS=t.S=0 S=1s5S=6^S=t8iS=9S=<3sAS=BpS=tELS=s QtnQQrO_ "$* +-/49>@N> 0 Z!$(*.3l5@DA L1A!%(*,-w/14 v JtJsJJt)JJsvJJt@J J#'s+J,WJt.cJ/J1|s5J6AJt8MJ9J<sAJBTJtGJs I?tnI?I?rG[? $#%l'*, 027C8=w?EEDk #(* +l,.{1` 8};D@p !&2$7:= EB\bw!@s$u& -Q0#2v5 6<8>DEG"?AjM%}*[.*0]8:="!#a&v)6:<Cw;% !#1v ::t::s::}::tb::::s::::t::sM::t"::"::)s.]::/::t0K::s1::2::t3::4G::r8a! $&F,-1}5L7=AD FG6])p 2 s |q$a2%2(7+/248=@Br /Yp"%(*Z/05+v +t+s++t++s+e+t +s++t+ G+*Is*I]*Itt*Is%*It *Ip*I v (t(s(-(t(u(s#((tN(s5( (t'((&s&]&tt&s%&t &p&v %8t%8s%8-%8t%8u%8s#%8%8t0%8s %8 %8t& %8&l%8#s#]#tt#s%#t #p#v !t!s!8!t!!s.!!t!sn!B!t_!! 's '] 'tt 's% 't 'p 'v wt wsw:wtwws0wwt<ws#wwtwwws]tts%t pv t:s8t(stst+gsg]gttgs%gt gpg v tstssX4 6t"s#$t)*s]tts%t p v VtVsV8VtVVs.VVt?Vs'VVtV{Vs]tts%t p v tYsVtFst7st%%sEsE]EttEs%Et EpE v tP sN  t > s  t! s" #X t(u (  s ] tt s% t p v 5t 5s 58 5t 5 5."$Cs. 5. 5t3 54^ 5y)TVm$=INLINE{RETURN[[time[v]]]};--i.e.time[]isthecurrenttimetv:PROC[v:RTBasic.TV]RETURNS[Value]=INLINE{RETURN[[tv[v]]]};type:PROC[t:RTBasic.Type]RETURNS[Value]=INLINE{RETURN[[type[t]]]};Parsingtheinputstream:GetCedarToken,GetToken,GetInt,GetReal,GetRefAny,...Parsingtheinputstreamasasequenceofcharacters:GetSequenceCharProc:TYPE=PROC[char:CHAR]RETURNS[quit:BOOL_FALSE,include:BOOL_TRUE];GetSequence:PROC[stream:STREAM,charProc:CharProc_LineAtATime]RETURNS[ROPE];readscharactersfromstreamuntilEOForquitisTRUE,includingthosecharactersforwhichincludeisTRUE.Forexample,thedefinitionofLineAtATimeisRETURN[char=CR,FALSE].Thuss.GetSequence[]willreadtothenextCRandreturnthecharactersreadasarope.LineAtATime:CharProc;EveryThing:CharProc;definitionis{RETURN[FALSE,TRUE]}i.e.in.GetSequence[EveryThing]returnsthecontentsofin.ParsingtheinputstreamasasequenceofCedarTokens:GetCedarTokenGetCedarToken:PROC[stream:STREAM]RETURNS[ROPE];usesCedarScannertoscantheinputstreamforthenextmesatoken,whichisreturnedasarope,e.g.forthestreamIO.RIS["[$foo,a.b,3.2]",successivecallsonGetCedarTokenwouldreturntheninetokens"[""$foo"",""a"".""b"",""3.2"and"]".GetCedarTokenautomaticallyfiltersoutallcomments.Forconvenienceinusewiththeinterpreter,&istreatedasaregularcharacter,ratherthancausingasyntaxerror,i.e."&23"willparseasasingletoken.GetAtom,GetBool,GetCard,GetInt,GetReal,andGetRopedescribedbelowprovidewaysofparsingtheinputstreamintoobjectsofthecorrespondingtype.Iftheclientknowswhattypeofobjectisnextexpected,hecanusetheinputroutineforthattype,e.g.i:INT_stream.GetInt[],ratherthancallingGetCedarTokenandthenconvertingtheresultingropetothecorrespondingtype.GetRefAnyprovidesacompromisebetweenthesetwopositionsbyreturninganobjectthatisaREFtothecorrespondingtype,e.g.REFINT,REFBOOL,etc.TheclientcanthendiscriminateonthetypeoftheREF.Basicinputroutinesforeachvaluetype:GetCard,GetInt,GetReal,...Example:i:INT_stream.GetInt[];Note:allofthefollowingproceduresusetheCedarScannertoobtainthenexttoken.Ifthetokenisoftheappropriate'kind',thecorrespondingvalueisreturned,otherwise,raiseSyntaxErrorwithanappropriatemessage.SyntaxError:ERROR[stream:IO.STREAM,msg:ROPE_NIL];GetAtom:PROC[stream:STREAM]RETURNS[ATOM];raisesSyntaxErrorifnexttokenisnotanatom.GetBool:PROC[stream:STREAM]RETURNS[BOOLEAN];returnsTRUEifnexttokenisTRUE,FALSEifFALSE,otherwiseSyntaxError.Note:ifyouareplanningonusingGetBooltoaskforconfirmation:UserExec.ExecConfirmandUserExec.ViewerConfirmprovideconvenientandstandardwaysofaskingforconfirmation.Theseproceduresalsopostmenubuttonsandhandlethecasewhere7tb&sb&]b&ttb&s%b&t b&pb& r!b&"]b&#Z%)r*-*1v `|t `|s`|`|t`|`|s`|`|t`|so`|C`|t!``|!`|^s^]^tt^s%^t ^p^ v ])tr])so])])t])_]) s])])t$])$c])[s[][tt[s%[t [p[ p WZqWZ WZ p&~WZq'WZ(WZ.kp2cWZq3lWZ4WZp8aWZq9iWZ:WZA+v TIKC"# q*T+T v QCtQCsQCdQCtQCsQCQCtsQCQCs`QC +QCt"QCs#QC$tQCt)QC)QCs-QQC. QC02$t5QC6QCs;QCNz@3J@JrAJzBJCUJrFVJFJHK!#B%(+#-14% :=?R@v E tEEv C tCCsdCrBQ tBQs0BQtBQs{BQtBQsBQ BQt#!BQ#BQr$BQ%BQ&8 <>D;Ev ?IKC"#'q-?.:? v <; tx<;sv<;<;t<;e<;sO<;<;t$<;s%<;%<;t*<;s*<;t-<;.`<;r: ]p $?(*-0&37;<B[DEH8a3 #&-) 0335& >BF7C*}!#&(,c/26 ; D[5C>u #%'*-7 4$57;=J>~C' 3 r$&&Y*-202s37y 1wq1wy1w1wq1wy1w"1wqo1wy1w 1wq#v1wy$1w%1wq)1w*1wy-1w.1wq4=1w51w:>D;G /zI#%{' 146N8<ADG .(6'8"x$(-0 26y9).(9.(:=k?qH.( , y],q, q!,",$' .`06?9\:=D F'y *qh*/* !'3*-Y35 ; <ACE2yFT*GR*q )2 4 ?yY)2 W)2"q$)2y%)2&)2)&q-)2.)2037d:=> EG/ ' y%'#'q'v $9 3~~q"$9$$9(-3r !t* !NI9 "%'h 0.158F;[?xACRG zs O &*r+1 7; BE  v  tNsLt]st$%s( (t+s--t/pv ,tk,sh,,t,X,sB,,t ,s ,!,t&,s'H,t*,s+%,r !#F%'v tstsj t4s  t%s&t+, r/lF %z*+1j7U  1#>(*&,.  !05 DtG 5Dl # *C-/38_;?aADy) TVm$}theuserhastypedaheadbeforetheneedforconfirmationarose.GetCard:PROC[stream:STREAM]RETURNS[LONGCARDINAL];GetInt:PROC[stream:STREAM]RETURNS[INT];GetReal:PROC[stream:STREAM]RETURNS[REAL];GetRope:PROC[stream:STREAM]RETURNS[ROPE];raisesSyntaxErrorifnexttokenisnotarope.GetId:PROC[stream:STREAM]RETURNS[ROPE];raisesSyntaxErrorifnexttokenisnotanidentifier.ReadingRefAnys:GetRefAny,GetRefAnyLineGetRefAny:PROC[stream:STREAM]RETURNS[REFANY];Usecedarscannertoparsetheinputstream,thenreturntheresultingtokenasaREFtotheappropriatetype,e.g.REFINT,REFREAL,REFBOOL,ATOM,ROPE,orLISTOFREFANY,etc.^infrontofanobjectisignoredinorderthatreadandprintbeinverses,e.g.^3willproduceNEW[INT_3].Identifiersarereadinasatoms,e.g.foowillproduce$foo.Theinputsyntaxforlistsis(followedbyasequenceoftokensterminatedby),e.g.(abc)willreadinasLIST[$A,$B,$C].Commasarepermitted(andignored)betweenelementsofalist.GetRefAnyLine:PROC[stream:STREAM]RETURNS[LISTOFREFANY];callsGetRefAny,constructingalistofthevaluesreturned,untilanobjectisimmediatelyfollowedbyaCR...e.g.ifusertypesFOOFIEFUM{cr}returns($FOO,$FIE,$FUM).IfusertypesFOOFIEFUM{sp}{cr}continuesreadingonnextline.Usefulforlineorientedcommandinterpreters.(NotethataCRtypedinsideofalistsimplyhasthesameeffectasaspace,i.e.terminatesthepreviousidentifier,butnotthereadoperation).Parsingtheinputstreamasasequenceofarbitrarytokens:GetTokenGetSequenceparsestheinputstreamintoasequenceofcharacters,e.g.thenextline.Theapplicationthentypicallyhastoparsethissequenceintosmallerunits,calledtokens.GetCedarTokenisonewaytodothis.However,occasionallytheusermaynotneedthefullpowerofthecedarscanner,ormaywishtoemploysomeotheralgorithm.ThecharProcargumentofGetTokendescribedbelowprovidesforalimitedformofparsingbydividingallcharactersintothreeclasses:{sepr,break,other}.Aseprcharacterisacharacterthatseparatestokens.Seprcharactersneverappearintokens.Forexample,formostapplications,SPwouldbeasepr.Abreakcharacterisacharacterthatisatokenallbyitself.Forexample,forsomeapplications,]mightbeabreakcharacter.othercharactersareeverythingelse.BreakProc:TYPE=PROC[char:CHAR]RETURNS[CharClass];CharClass:TYPE={break,sepr,other};GetToken:PROC[stream:STREAM,breakProc:BreakProc_TokenProc]RETURNS[ROPE];skipsovercharacterswhichbreakProcsaysareseprs,andthenreadsuntilitencounterseitherabreakorsepr.Ifbreakisthefirstthingencountered,returnatokenconsistingofthesinglebreakcharacter,otherwisereturnthesequenceofothercharactersreadbeforethefirstbreakorsepr.ThuseachtimeyoucallGetToken,yougetbackaropeconsistingofeitheroneormoreothercharacters,orelsearopeconsistingofjustasinglecharacterthatisabreakcharacter.Forexample,supposeyourapplicationinvolvedparsinganinputstreamintoasequenceofidentifiers8rb&>#. $)&u)+ 3v `zt`zs`z`zt`z`zs`z~`zt`zs `z!d`zt&`zs&`z*t0`z1U`zv ^t^s^^ts^^s^^^t^sq^ E^t%b^s%^t'^(4^v ]!t]!s]!]!tq]!]!s]!\]!t]!s o]!!C]!t&`]!s&]!t)]!*@]!v [ut>[us<[u[ut[u,[us[ut[us [u![ut&[us't*-[u*[urY !#F%&v VptdVpsbVp VptVpRVps;VpVptVpsVpVpt$Vps%AVpt(RVp(VprT !#F%' v QnCqQnQno xv NtNsN9NtNNskN Nt!6Ns"N"Nt(Ns(qN+!t-N.NrLdT $Q),0%2q7;=y>BCKR < "%*-27<>uBKDIOPJ=#,$)m+.1n4r7:`<0AD FHJE $' *+-n14569>*ADJF\5] !"(*(.r 5)78Y:<=?TADFD, 7"(+06 ;=0>ev A\ t?A\s=A\A\tA\-A\sA\A\t#A\s$A\%A\t*OA\s*A\-/2Gt4A\59A\r?( w !L#%.'z+1@4v6i:W; CH><\$z^P!>',1(5 :j;>BFE: $&),035:A 9 E"$W%',.{04179:>@ 7f>  #T%( v 4IKC"#)eq.84/b4 1H k!^$L%+-X 4369F*?e* (+v a(+ (+q8(+(+ ^qC$)Z, 26:<A)C & ) t  $v x$ ($qA$$) s!#&(*.y1$691< DE "\  v q %K v tRsP ts4t|s  t#^s$E%t*6* v tstZ? ov ~t~s~~t~~s~q~t ~!x~ (s/0 s8~8~t=~s=~t@~A_~rvd %9(t*p*r-i.F037|:< BFt+r+g+tp++r++O #'% .34C8 >E?B4trR"%D*t,-Cr0&069=?tBCrFGItrVq \ Wv-v\\q\l\"$G'{(+ 137s: ;v?>\?\qB\Ce\  g q"(o+=,v- . q1 27  5 0 "U(,.27*:;QALC y) tTVm$separatedbycommas,whereyouwanttomakesurethatthereisacommabetweeneachidentifier,butdon'tcarewhetherthereareanyspacesbeforeorafterthecomma.Hereiswhatyoumightwrite:YourProc:BreakProc={RETURN[IFchar=',THENbreakELSEIFchar=SPTHENseprELSEother]};SuccessivecallsonGetTokenusingthisBreakProcwouldalternatelyreturnidentifiersand",".SinceitisagoodexampleoftheuseofGetSequence,hereisthedefinitionofGetToken:GetToken:PROC[stream:STREAM,breakProc:BreakProc]={anySeen:BOOL_FALSE;proc:CharProc={SELECTbreakProc[char]FROMbreak=>{include_NOTanySeen;quit_TRUE};sepr=>{include_FALSE;quit_anySeen};other=>{include_TRUE;quit_FALSE;anySeen_TRUE};ENDCASE=>ERROR;};RETURN[GetSequence[stream,charProc]];};ThefollowingproceduresmaybeusefulinconjunctionwithGetToken.WhiteSpace:BreakProc;ReturnssepronSP,CR,LF,TAB,otherforallothersIDProc:BreakProc;ReturnsseprforSP,CR,ESC,LF,TAB,comma,colon,andsemicolon,andotherforallothers,i.e.s.GetToken[IdProc]isapproximatelythesameastheolds.GetRope[].TokenProc:BreakProc;ReturnsseprforSP,CR,ESC,LF,TAB,comma,colon,andsemicolon,breakfor[,],(,),{,},'",'+,'-,'*,/,'@,'_,andotherforallothers,i.e.s.GetToken[TokenProc]isapproximatelythesameass.GetCedarToken[](butrealnumbers,quotedliterals,quotedtext,etc.arenothandledthesame).SkipOver:PROC[stream:STREAM,skipWhile:BreakProc_WhiteSpace];skipsoverallseprs,oruntilitreachestheendofthestream.IfskipWhile=NIL,nocharactersareskipped.StreamPropertyListsThestream'spropertylistcanbeaccessedandusedbytheclientforstoringandretrievingdataassociatedwithaparticularkey,thesameaswithanatom'spropertylist.TheproceduresStoreData,LookupData,andRemoveDatacorrespondtoPutProp,GetProp,andRemProp.StoreData:PROC[self:STREAM,key:ATOM,data:REFANY];addsanentrytopropertylist,orreplacesexistingone.AddData:PROC[self:STREAM,key:ATOM,data:REFANY];likeStoreData,exceptaddsittofrontofpropertylist,evenifsomethingalreadythere,i.e.socanusepropertylistasapushdownlist.9q b) !#'W*R-"023G8=@ G ` oF:"s&(+."3M68,;>@B7v ^q^^F+s^^q^s'^q ^!O^#%s&^'^q*^+P^s.^^/^1q3 ^3^6/s8^8^9q=p^=^s@i^A#^qC^DY^ [ v[[q2[["})-N 485 >Ad Y cx1!" +.02e 8:it U ;# * 12T{RY P1O,#[)M,1-1MW*O$_'C(1Ke$v'Z(.j35p1J(1HVF! Eq @  "$ ,/4v < t#<!< r;y;;rp; ;c y$<;% ;r(;(;*D,?v 7ta7_7 r5y55rp558!$f(t,B5r-5-513 4Vy4VV4Vre4V4V ,- 6Q8<=@ 2 v /Yt/Y/Y r-y--rp--8!$f(t,B-r----13 y,r,r,+ulk"#%' )*[y*[V*[re*[*[ ./ 8; >t(]8%* .346S8;)=BDv %]t%]s%]2%]t%]z%]sd%]%]t .%]! %] (.05 r#vd_ [%%'q)+-243:  F!%A&,3.1349>ZBDPF  A"zy)dTVm$LookupData:PROC[self:STREAM,key:ATOM]RETURNS[REFANY];returnsfirstoccurrenceofkeyRemoveData:PROC[self:STREAM,key:ATOM];removesfirstoccurrenceofkeyfrompropertylistDefiningnewkindsofstreamsAstreamisdefinedbyspecifyingacollectionofprocedureswhichimplementthevariousoperationsthatastreammustsupport,suchasreadingorprintingacharacter,erasingacharacter,closingthestream,changingitsechoing,etc.Notalloftheproceduresneedtobespecified.Forexample,allproceduresrelatingtooutputneednotbedefinedforaninputstream.Similarly,someoperationsthatarenotdefinedcanbecarriedoutintermsofothersthatare,e.g.iftheGetBlockprocedureisnotspecified,acalltoGetBlockwillbeautomaticallytransformedintoncallstoGetChar,etc.Finally,ifthestreamislayeredontopofanotherstream,itwillautomaticallyinheritthelatterstreamsdefinitionsforthoseproceduresthatarenotexplicitlyspecified.Foramorecompletediscussionofwhatitmeanstodefaultastreamprocdure,seethediscussionbelowfollowingthedefinitionofCreateProcsStream.Thefollowingisanexampleofdefininganewkindofstream.Anexample:definingastreamtotheMessageWindowTheapplicationistodefineastreamwhichcanbeusedforoutputtotheViewerMessageWindow.SincetheMessageWindowinterfaceallowsonetodisplayropes,theideaistodumpthecharactersintoarope,andthendisplaytheropeinthemessagewindowwhenaFlushisexecuted.WecanwritecharactersintoaropeusingaRopeOutputStream,describedabove.Furthermore,ifwemaketheRopeOutputStreambethebackingstreamforourMessageWindowStream,wedonotevenhavetodefinePutChar,butcansimplyallowforthatoperationtobeexecutedbyacallthroughtotheRopeOutputStream'sPutChar.AllwehavetodoistodefinewhatFlushandResetmean:MessageWindowStreamProcs:REFStreamProcs_NIL;--theblockofproceduresforthestream.Initializedthefirsttimeoneofthesestreamsiscreated.CreateMessageWindowStream:PROCEDURERETURNS[STREAM]={IFMessageWindowStreamProcs=NILTHENMessageWindowStreamProcs_CreateRefStreamProcs[flush:MessageWindowStreamFlush,reset:MessageWindowStreamReset,name:"MessageWindow"];--initializetheblockofproceduresRETURN[IO.CreateProcsStream[streamProcs:MessageWindowStreamProcs,backingStream:IO.ROS[],streamData:NIL]];};--ofCreateMessageWindowStreamMessageWindowStreamFlush:PROC[self:STREAM]={r:ROPE_self.backingStream.GetOutputStreamRope[];--getthecharactersthathavebeenprinted.i:INT_0;self.backingStream.Reset[];--resettheropeoutputstream.WHILE(i_Rope.Find[s1:r,s2:"\n",pos1:i])#-1DOr_Rope.Replace[base:r,start:i,len:1,with:""];--changecrstospaces(sincemessagewindowisonlyonelinehigh!)ENDLOOP;10v b& tpb&snb&b&tb&]b&sab&b&t ,b&!b&s$b&$b&t'b&s(yb&)Mb&t.jb&s.b&1}t4 b&4pb&r`tu 4v ] t]s]B]t']]s]-]t X]!5]s$D]%]t'](!]r[_2 c $-){p W.TXq S i% h %'P .G2E9;j@# F R* '""$v)+ 1W67V =BUD Pe #C *b-/1 7:@B N.#(%'+0 6: ADG M4vfv#!%(+@-/(y1M42M4q7M48M4>s?BR He K vy#K7KqKK6% ! )L,#-m0{y2(K3   $'F(r,1 8y:5=>C5D F o $+-o 3y5sF6pFqAF D B3d"#&*+p ? ; "%,Vq < s!%(*-0P4692>C :   3$`' (-k1w368;9=@J F 96 F?" !$* /g3L48:U@CUF 7 N;`$)/3 AD 2{M ".#(+s/T2 5t /5sc/57/5t!/5!/5 (s*/5+l/5t,/5./5/157a >h@C1- !#%i(-/R **s****&t,**s-**t1**2**4s(xt(x(x!s#m(x$V(x%t)(x*(x;zB&% #m!X |  i) sWtWsZWtWW(: sBtst/ s!"}t#$3 s8t!"s%%t)*,sdt )0D146d <?BBAsotq #&;)k-s,tU,,B 8!%)4*,s.,/q,t z( S#%')v- .?02K69:?BS  "%fs !t !y)e TVm$ MessageWindow.Append[message:r,clearFirst:TRUE];--displaytherope};MessageWindowStreamReset:PROC[self:STREAM]={self.backingStream.Reset[];--resettheropeoutputstream.MessageWindow.Clear[];--clearthemessagewindow.};CreateProcsStream:PROC[streamProcs:REFStreamProcs,streamData:REFANY,backingStream:STREAM_NIL]RETURNS[stream:STREAM];thegeneralmechanismforimplementingstreams.streamProcsisintendedtobetheresultofacalltoCreateRefStreamProcs(describedbelow).CreateRefStreamProcsisresponsibleforinsertingtheappropriatedefaultproceduresforthoseoperationsnotexplicitlyimplementedbythestream.Seediscussionofdefaultoperationsbelow.backingStreamisusedwhenbuildingalayeredstream:thoseoperationsnotdefinedinstreamProcswillbeautomaticallyinheritedfrom(passeddownto)thebackingStream.Note:ifnobackingStreamisspecified,theminimumrequiredtoimplementastreamtobeusedforinputisgetCharandendOf.TheminimumrequiredtoimplementastreamtobeusedforoutputisputChar.Everythingelsecanbedefaulted...Inotherwords,iftheseoperationsareimplemented,theonlywayofencounteringthesignalNotImplementedForThisStreamisiftheclientexplicitlycallsGetIndex,SetIndex,GetLength,SetLength,GetunsafeBlock,orPutUnsafeblockwhentheyarenotimplemented,oriftheclientattemptstoobtaininputfromastreamintendedtobeusedonlyforforoutputorviceversa.Allotherprocedureswillbehandledviathedefaultsdescribedbelow.CreateRefStreamProcs:PROC[getChar:PROC[self:STREAM]RETURNS[CHAR]_NIL,endOf:PROC[self:STREAM]RETURNS[BOOL]_NIL,charsAvail:PROC[self:STREAM]RETURNS[BOOL]_NIL,getBlock:PROC[self:STREAM,block:REFTEXT,startIndex:NAT,stopIndexPlusOne:NAT]RETURNS[nBytesRead:NAT]_NIL,unsafeGetBlock:UNSAFEPROC[self:STREAM,block:UnsafeBlock]RETURNS[nBytesRead:INT]_NIL,putChar:PROC[self:STREAM,char:CHAR]_NIL,putBlock:PROC[self:STREAM,block:REFREADONLYTEXT,startIndex:NAT,stopIndexPlusOne:NAT]_NIL,unsafePutBlock:PROC[self:STREAM,block:UnsafeBlock]_NIL,flush:PROC[self:STREAM]_NIL,reset:PROC[self:STREAM]_NIL,close:PROC[self:STREAM,abort:BOOL_FALSE]_NIL,getIndex:PROC[self:STREAM]RETURNS[INT]_NIL,setIndex:PROC[self:STREAM,index:INT]_NIL,getLength:PROC[self:STREAM]RETURNS[length:INT]_NIL,setLength:PROC[self:STREAM,length:INT]_NIL,backup:PROC[self:STREAM,char:CHAR]_NIL,userAbort:PROC[self:STREAM]RETURNS[abort:BOOL]_NIL,setUserAbort:PROC[self:STREAM]_NIL,resetUserAbort:PROC[self:STREAM]_NIL,setEcho:PROC[self:STREAM,echoTo:STREAM]RETURNS[oldEcho:STREAM]_NIL,eraseChar:PROC[self:STREAM,char:CHAR]_NIL,11tb&#m$ s+Zb&,b&t.b&.b&0k168`} ]*sz]*"]*t!]*"]*s%]*%]*t)]**]*,[ #&;)k-Y_"%*gX.v TtTsT.TtT T s$&T$Tt&T'T / s6T7T9t<TO=OCyN:rN:N: &f(.0e 7< BDL \  %j'D).G0 7+8=N CyJ r7JJ 5%p&+L0$3 :<A.yIB rrIBZIB $:)-15U7s9 q FJN  $&u,2W4:<@|B)DGR EN |&,c.46#:5ArCH# Cw   @ ~[ #\& /15 8K:W BE ?S !#&* 104;B; = 1 )-1I36 ?AC-E <t d$*,.15,79>m@LC@G< :] O? "%**W0v 7 t7 s7 ?7 t7 5as5ag5at5aE5asI5a5at5as5a 5at%5as%5at)>5a*%5as+5a,5at-5a3s3t3t3R3sV33t 3s33t$3s$3t(3)3s*3+z3t,32 s@22tc22s2i2t 2s!|2"P2t'2s'f2t*2+y2s-2-2t/20es-0e0etP0e0es0eV0et0e ]0es$0e%k0e'Gt*F0e+#0e s20e20et40e5e0esA?0eB(0etC0es.ti.. s..tP. 8.s!.".t#.-s|-b-t -!-s$#-$-t(-)-. s6t-7H-t;-<_- sDn-D-tFz-Ga-s+mt+m(s((t(}(s( (tK( ((s#($|(t' ('(s)~(*f(t+(&qse&q &qt&q&qs&q&qt&q &qs$&q%&q'.t1&q2\&q s9M&q:6&qt;&q<&qs$tV$>$s$$t$# sE# # th# # s# o# t## $v# ( 1!s2# 3# t4# !ws!w!wt!w!ws!w$!wtO!w6!ws!w !wt!!w$s$v$t$T$sX$$t"$ $s$ $t!${s{{t{u{sy{{tC{ {s"8{"{t%{s'Z{({t*{+{s-l{.U{t/x{s8t[sats t!Ht&es&t()s+H,1t-T(s ((t/((s(5(t`( =(s$($(t&('t(s)()(t+ ( s t-s3t ^s!F"t'7's,M,t.Y/@s01t2- s--t-d-sh--t 2-!-s%-&,-t'-(-s*B-+*-t,M-s]tsts##t&o'Vs()t* st!s(t Ss!:"t&'%s+=+t.h/Ps01t21 s11t1u1sy11t"C1#1s%<1&$1t'G1 s  t<  s B t#m $ s&e 'N t(q  s Q t / s3  t  s%= % t* s* + t0 1C s7* 7 t; < s>i ?R t@t  5 s 5 5t 5y 5s} 5 5t G 5!$ 5s$ 5%x 5t( 5( 5s*z 5+c 5t, 5y)e tTVm$currentPosition:PROC[self:STREAM]RETURNS[position:INT]_NIL,name:Rope.ROPE_NIL--usedforprintingthestreamitselfasarefany.]RETURNS[REFStreamProcs];createsaREFstreamprocs,supplyingappropriatedefaultsfortheNILprocedures.Intendedtobeperformedonlyonceforeachdifferentstreamclassandtheresultsaved,i.e.allinstancesofthisstreamcansharethesamestreamProcs.WhatitmeanstodefaultastreamoperationThedefaultprocedureistofirstcheckifthereisabackingStream,andifso,callthecorrespondingoperationinthebackingStream.IfnobackingStreamisspecified,thedefaultprocedureisasfollows:CharsAvail:checkwhetherendOfwasspecified,andifsoreturn~endOf[handle],otherwiseraisesignalNotImplementedForThisStreamasdescribedbelowEndOf:checkwhethercharsAvailwasspecified,andifsoreturn~charsAvail[handle],otherwiseraisesignalNotImplementedForThisStreamasdescribedbelowGetBlock:implementvianCallsonGetCharPutBlock:implementviancallstoPutCharFlush,Reset:Nops,donotsignalClose:ifabort=NIL,callFlush,otherwise,callReset.donotsignalBackup:replace,i.e.ambush,thestream'soriginalStreamProcsbyadifferentsetofproceduresinwhichgetChar,getBlock,endOf,charsAvail,andresethavedifferentdefinitionswhenthestreamisinthe"backedup"state.Theremainingprocedurescallthroughtotheoriginalprocedures.Whenthecharacterhasbeenconsumed,thestreamsoriginalproceduresarerestored.Notethatthiscausesthestreamtorunmoreslowlyonlywheninthebackedupstate.SetEcho:similartoBackup,i.e.ambushesthegetCharandgetBlockprocedures,causingthemtoalsooutputtotheindicatedhandle.Thiscausesallprocedurecallsinthestreamtorunmoreslowlyduetotheextralevelofprocedurecallandlookup;CurrentPosition:ambushesthestreamsputCharandputBlockprocedures,andcountsthecharactersastheygoby.SincethisdoesnotoccuruntilthefirstcalltoCurrentPosition,charactersthatwereoutputbeforethiscallwillnotbecounted,i.e.thefirstcalltoCurrentPositionwillalwaysreturn0,andsubsequentcallsuntilthefirstCRisseenwillreturnthenumberofcharactersoutputsincethefirstcall;EraseChar:output\followedbythecharacter.DefaultingEraseChardoesnotaffecttheperformanceofthestreamonotheroperations.Forallothercases,thedefaultprocedureistoraiseSIGNALSignal[NotImplementedForThisStream](i.e.clientcanresume),ifthecorrespondingoperationdoesNOTreturnavalue(i.e.isexecutedforeffectonly,suchasputChar),orraiseERRORError[NotImplementedForThisStream]ifthecorrespondingoperationrequiresareturnvalue,suchasgetChar.Ingeneral,thedecisionaboutwhetherornottoimplementaparticularoperationforastream,mustbemadeonthebasisofperformanceandfrequencyofuseversusconvenienceForexample,ifthestreamimplementsbackupitself,itcanincludethenecessarycodeinitsowngetChar,getBlock,reset,etc.,sothattheseprocedureswillcontinuetorunfast,evenwhenthestreeamisbackedup.However,itismoreworkfortheimplementor.Forexample,viewerstreamsimplementSetEcho,butInputRopeStreamdoesnot.Similarly,aneditedstreamimplementsbackupbutviewerstreamdoesnot,onthegroundsthatmostcallstoaviewerstreamthatinvolveparsingandbackingupwillinsteadbegoingtoananeditedstream.12tb&sb&b&tqD5EW@b x U*)a!Oq R@ $%p)*t+ 5U89{;>1@ P !0#- ,t- 368:AQBDYv Nj qtNjNj$!$l *-/1 5e?FT L#%B+lv J9qJ9J9 #R )`,-m/+3T@0FT H#%B+lv FqFF  "v C~qC~C~o !v @qp@n@tzv >jqC>jA>jA&!U '*b.03v ;qm;;!&+ 356<>@ G :9 e '*F-06 =yA;CH# 8 4"% ,/`46p8> Ew 6_J  #_(V-b 4k6 )wx <!5&)+.e02<?^CH ' C!$%(+O/178 ?CCG/ &Dv #q1##~4 "l ( /d69;?=A " + c=b%'n)+s,t-q1V2" z O0 '. s1T2=q4?48r9=M@AvG6 :izK!z#s':(r:q,:-:!DF   k!%),.   L~#%')01 7>@<AbF' b Jz #&P,.15O =*?EG/ \ x !`#(*04.57:@E >  F%'x),036;<`ACZ l < %)/T4(9@G ;~^ #%).l 5:=dAF^ $"!"#(,n/&38;@@KBGD v fWGvy)e TVm$QAmbushProcsStream:PRIVATEPROCEDURE[self:STREAM,streamProcs:REFStreamProcs,streamData:REFANY,reusing:STREAM_NIL];usedtobuildalayeredstreamontopofanotherstream,forthosecaseswherethedesiredeffectistohaveanyprogramthathasholdofselftoseethenewbehaviour.Implementedbysmashingselftopointtothenewprocsanddata,withabackingstreamthatcontainsthesamedata,procs,etc.asselforiginallydid.ifreusingisnon-NIL,itisreusedandnoallocationsareperformed.Typicallyreusingissavedonthepropertylistofastreamwhichisgoingtobeambushedandthenunambushedrepeatedly.UnAmbushProcsStream:PRIVATEPROCEDURE[self:STREAM];inverseofAmbushProcsStream,i.e.elevatesthebackingstreamtoself.Nopifnobackingstream.DefiningnewstreamoperationsCreateRefStreamProcstakesasarguments22predefinedoperationsonastream.Supposewewanttodefinenewoperationswhichmightnotappearinthisinterfacewhicharetobe(optionally)implementedbyavariouskindsofstreams.TheprocedureImplementsallowsustodothis.ItisusedtoprovideagenericimplementationforAppendStreamsforallstreamsthatdonotimplementthisoperation(currentlynostreamdoes),toimplementChangeDeliverWhenforbotheditedstreamsandviewereditedstreams(seeViewerIO),andalsothemechanismusedtosupplythedefaultbehaviourforBackupandCurrentPositiondescribedabove.Forexamplesofitsuse,seeIOImpl.Implements:PRIVATEPROC[self:STREAM,operation,via:PROCANYRETURNSANY];usedtosupplytheimplementationofanoperationotherthanthosespecifiedasargumentstoCreateRefStreamProcs.'operation'isthegenericprocedure,andViaistheimplementingprocedureforthisstreamclass.Viaischecked(usingtheRTinterfaces)tomakesureitisofthecorrecttype.(Thenamesoftheargumentsaswellasthereturnvaluesmustagree.)Ifitisnot,thesignalIO.Error[ProcedureHasWrongType]israised.Ifthetypeiscorrect,ViaissavedonthepropertylistofthestreamProcs,sothatthetypecheckingneedbedoneonlyonceforeachstreamclass.SubsequentcallstoImplementsforthesamestreamclassareessentiallynops.Whenthe`operation'isinvoked,`via'willbecalledwiththesameargumentsasthegenericprocedurewascalledwith.Forexample,ifCreateRefStreamProcsdidnottakesetLengthasanargument,thisoperationcouldbeimplementedforaparticularstreamclassbyperforming:stream.Implements[SetLength,MySetLength],whereMySetLengthisoftypePROC[self:STREAM,length:INT].UncheckedImplements:--Evenmore--PRIVATEPROC[self:IO.STREAM,operation,via:PROCANYRETURNSANY,data:REFANY_NIL,procRef:REFANY,key:ATOM];usedbyimplements.CallingdirectlyandspecifyingprocRefandkeyenablesavoidinguseofRTinterfacesLookupProc:PRIVATEPROC[self:STREAM,operation:PROCANYRETURNSANY]RETURNS[proc:REFANY];PF(PrintFormatted)PackageConceptPutF(andPutFRandPutFList)produceoutputaccordingtoacollectionofValuesandaformatcontrolstringwhichcanincludingembeddedformatcodes.TheValuesthataretheargumentstoPutFare13vb&tjb&shb&b& t'b&(_b&s+cb&,b&t0-b&1 b& s9$b&9b&t;b&CTG7VNb!$ + vSt9Ss7SS"t)S*.Ss-2S-St1S2_Sr QfB#N%*x,16<7:=>@Op K^ v H)q)H)H)$Y&[ -i 436V7<B#DgG F z!&X'*046b89 A= D = v&D'#Dq.D.D2I4/58;<>.ACDHe C3 Pl $K&f(5-/13:=0C8 A K>*P,/4#9%;@]D ? $ %o)+00 27>AwF >= e!' (*-n/v : t:s:p:(t::s : :t$:%: ,Ds.:/:25;rt>:>d:r9? "$`&S,J/26l;=D7v tc7v7vr#7v#7v%P',H 25o89p; 5 4+!$T%*.1A3 :2;?BhCE+F4(_!({*4-.159(@k+  * ht* * r'* ([* ),Vt/]* /* r5* 6c* 7l9_?BV(yb 8 `! ',/Z15 t&# r,&,&t0&2$& r9m&9&:<|t?b&@3&%*rp%*v !tV!sS!!S!/"['t+G!+!s.!/!t5!5! 0\ 683<?N@mD 5 0/"&+.258L:ACG;y)e TVm$associatedwiththeformatcodesintheorderthattheyappearintheformatstring.Forexample:h.PutF["Thisis%gina5positionfield:|%5d|",rope["aninteger"],int[17]];wouldproducetheresult:"Thisisanintegerina5positionfield:|17|".Ifaformatcodeisencounteredwhichisnotrecognized,thesignalIO.Signal[UnknownFormat]israised.Iftherearenotenoughformatcodestomatchthevaluessuppliedasarguments,ornotenoughvaluesthen???PreDefinedFormatCodesTheValuerefAnyisacceptedbyallformats;ifdereferencingyieldsavalueofanacceptabletype,itisprinteddirectly.Otherwise,if%gor%hareused,IO.PrintRefAnyiscalled.Ifsomeothercodewasused,theSignalIO.Signal[UnprintableValue]orIO.Signal[TypeMismatch]israised.IfthissignalisRESUMEd,some'#charactersareprinted.Inthefollowingdescriptions,"number"meansaValuethatiseithercard,char,int,real,ortime.CHARACTERSpassedtoanumberroutineprintastheirAsciicode."string"meansaValuethatiseitherastring,rope,text,bool,oranumber.BOOLEANspassedtoa"string"routineprintasTRUEorFALSEandCHARACTERsprintascharacters.%e:acceptsnumbers.LikeFortranEformat,printsin"scientificnotation"(mantissaandexponent).%f:acceptsnumbers.LikeFortranFformat,printsin"fixedpoint"format.%g:acceptsallvalues.Printswhateveryougiveitsensibly.Whenindoubt,use%g.%h:like%g,exceptthatcontrolcharacters(code<40B)printas"^.%l:acceptsROPEs.ChangeslooksforViewerStreams,isaNOPforallotherstreamssothattheclientdoesnothavetoknowwhetherheisprintingtoaviewerorafileorwhatever.Thevalueisinterpretedasasequenceoflooks,e.g.h.PutF["Makethis%lbold%lforemphasis",rope["b"],rope["B]]willprint"Makethisboldforemphasis".(NotethatBmeansremovetheboldlookbecauseitisshift-b.)Thecharacterspacehasthesameinterpretationasfortioga,i.e.removesalllooks.%r:acceptsnumbers,interpretsastimeintervalinseconds,andprintsasHH:MM:SS%t:acceptsnumbersandTime[],printsinusualdateformatwithtimezone(e.g."PDT")Thefollowingformatsapplytoallnumbers(andtoBOOLEANswiththeconversionTRUE=1andFALSE=0).(ToprintaPOINTER,LONGPOINTER,REF,etc.valueasanumber,PUNitintoanumberofthecorrectlengthbeforeconvertingtoaValue.)%b:printinoctal.%d:printindecimal.%x:printinhex.FieldWidthSpecificationsInformationaboutprintingaparticularvaluecanbeinsertedbetweenthe"%"andthecodeletter.Isthistrueforallcontrolcodes???Fieldwidth,leftorrightjustification,andzerofillingcanbecontrolled.Thedefaultistoprintthevalueinitsentirety,withnospacingoneitherside.Ifanumberispresentbetweenthe"%"andcode(e.g."%6d"),itisinterpretedasaminimumfieldwidth,usefulforprintingcolumns,etc.Extraspacesareinsertedbeforethenumber(rightadjusted)tofillouttotheindicatednumberofspaces,14q b) XsN"'%(+0@14N8<? _ '~"'-5 3= ],s Z "]"$ X/ e 7 j!o"%> ,s.2CE5 V x ia!6"')-3X5 < =@mEa Tv T Tp P cq Mg u & 't 04 5;8:< CXFH# K ="9$~( 13[79<@%C]E J It"#349;G=AsC7JD JqHJ Hq  )} E   #(W)-026:q>@DFs DK q2DKDKFp#e&({+/4 AG !"'L*.-135s;VA<AqAABAFqHC @%#Ss@%@%q@%R@%s[@%@%q"c@%#@%s%@%%@%q-+@%-@%02A =p =q = x4s >=q!|=&O*;+ 2V8t>A? ;(p ;(q y;( v5s;(q!9;(& )+/4$ 8p 8q 8 uv"R% ')M/_3x5&9; 6+p 6+q 6+ ~d2 $R()G,/168 3p 3q l3 us?33q313u! +,.31469>@CdE 2 }:t &'(-S/0;24d:=lAB| 0^ r $'D-d/ 6 =ZCdF' .vd..q.. "% &*0 259>a?AhF -_ ${&)(f,&.b35 *p *q * PY 1"W'V).r1*5s6*7*q8*s9 *q;-*s;*q (p (q ( Cg"T$'*/!2<5a8;< % p$'s)a%*%q/%0%25, s<%<%q?%Ai%BsE=%E%q #  *sg##q#sr#,#Xq$t#s%c#&7#q'#(#+7.01s7#8/#q:v#:#;>@EEG "F~ y  p q  . Ip Iq I . p q  ;p  q P  "c&(*/5w7:=@CjvGPH{P  e}/q!S%'), 47^:W>N@B  Hu 5"!'*,137;/<=C=D Ze#&$% -.06d9=BDM  5 Z$(z.\/2 4q6 8Z><CVDy)e TVm$runlessa"-"precedesthenumber(e.g."%-6d")toindicatedfillingwithspacesontheright(left-adjusted).If"-"isnotpresent,a"0"maybeinserted(e.g."%06d")toindicateright-adjustmentandfillingwithzeroesratherthanspaces.Inanycasethefieldwidthisaminimum,notamaximum.Shouldthesizeoftheoutputexceedthefieldwidth,itisprintedinitsentirety.Afieldwidthmayhavetheformxx.yy,viz:"%12.4g".Thesespecificationsareinterpretedbythefloatingpointnumberprintingroutines.Othertypesofconversionsignorethe"fraction".DefiningnewformatcodesUsersmayspecifytheirownprocedurestointerpretcodesfollowingthe"%"viaSetPFCodeProc.Forexample,h.SetPFCodeProc['z,ZProc]willcausesubsequentreferencesto"%z"tocallZProc.Predefinedcodes(e.g.d,e,f)mayberedefined.Onlyalphabetic(['a..'z])codecharactersarelegal,casedoesnomatter.SetPFCodeProc:PROC[stream:STREAM,char:CHAR,codeProc:PFCodeProc];when%charisencountered,codeProciscalledwithformat=???,andval=theValuethatcorrespondedtothiscontrolcode.PFCodeProc:TYPE=PROC[stream:STREAM,val:Value,format:Format,char:CHAR];Format:TYPE=RECORD[form:ROPE,first:INT];AnotherwayofdefiningnewcommandsisviaSetPFStarCodeProc.PFStarCodeProcsdifferfromPFCodeProcsinthattheydonottakearguments,i.e.noneoftheValuesthatcomprisetheargumentstotheoutputprocedureareassociatedwiththisPFStarCode.PFStarCodesareindicatedintheformatstringbyprecedingthecodewitha*insteadofa%,andthenfollowingitimmediatelywiththecodeletter(non-alphabeticcharactersfollowing*printasthemselves,e.g."**"printsas*),UndefinedStarCodesalsoraiseIO.Signal[NotImplementedForThisStream].PFStarCodeProc:TYPE=PROC[stream:STREAM,char:CHAR];SetPFStarCodeProc:PROC[stream:STREAM,char:CHAR,codeProc:PFStarCodeProc];PrintProcsPrintProcsallowtheclienttospecifyanalternativewayofprintinganobjectofaspecifiedtype.Usuallythisisemployedtosummarizetheobjectinsomeusefulway.Forexample,aviewerisanobjectoftypeREFViewerClasses.ViewerRecwhereViewerRecisaRECORDconsistingofnineteenfields!PrintingthisobjectwithoutaPrintProcwouldthusproducecopiousamountsofinformation,mostofwhichisprobablynotofinteresttotheuserwhosimplywantstoseewhichvieweritis.Instead,wecandefineaprintprocwhichprintsaviewershowingjustitsclassandnameasfollows:ViewerPrintProc:IO.RefPrintProc={h:REFREADONLYViewerClasses.ViewerRec_NARROW[ref];stream.PutF["{Viewer-class:%g,name:%g}",atom[h.class.flavor],rope[IFRope.Length[h.name]#0THENh.nameELSE"(noname)"]];};WeregisterthisprintProcvia:AttachRefPrintProc[refType:CODE[ViewerClasses.Viewer],refPrintProc:ViewerPrintProc];Followingthis,theviewerfortheinitialUserExecwouldprintas:{Viewer-class:Typescript,name:WorkAreaA:Executive}15q b!  R)>!*&j(-148:=&@` `y  n3o, /%x(.-/5,?BaFt ^/ZwK!$F'{+`,-47)8W?DF ]+ w] "#(^* + Z (`n $4'.^2 ;1= DG/ Y#-'$*,q 38:} p TPq Q | "$*N."4=69v;Q*B N6 [$ !%V , 1 4p :=oA,D9G Lv I6 tI6sI62I6tI6{I6sdI6 I6t$/I6% I6s(I6)_I6t+I6,I636 rG? $&T*5-11x3tG4Gr5EG6!G8:<?)CE 1v D6 tD6sD6ID6tD6sD6sD6tXD6D6s"D6#DD6t'oD6(LD6+/R4F9s=D6=D6t@jD6@D6v BtWBsTB BtBsBdBtBKBs ,B!Bt#=B$Bs'kB'Bt)vB)Bq @ %T')6BF( >b O.Of! )+Z.037:@pB < 5 "%C' 0! 8y:@BE ; =& ^!&a(')^+Q.1J7j8 @CFH 9l U #% (q* 1g376;#< 6_,g'v 3 t3s33tq3sV33t3 F3s%03%3t)3*3s.`3/+3t1323v 1t1s11t11s!1"1t&1'1s+1+1t.w1/T15p - q *h $y0 g"M (+-y248:U;uA'D (  4#'$(W,f/2/79=t>@DF ' a3!d(x)+@2 8v:H?DB %r 2f!$*3/T46 >B1DH# #G  #('+-F/38*9;X@BEV "# -C$ &(+.n2.3t  "/+-7 r ^"',+"7RG,a#(,0q  wU t EsEEt E!^E/ 7q lf*g"(- 0rt _] $!]%=(* y)e TVm$AttachRefPrintProc:PROC[refType:RTBasic.Type,refPrintProc:RefPrintProc];Usedtoregisteraproceduretobecalledforprintinganobjectofthespecifiedreftype.Theprocedurewillbecalledwiththecorrespondingrefandastream.IftheclassofrefTypeisnotreforlist,raisesIO.Signal[NotARefType].RefPrintProc:TYPE=PROC[ref:REFREADONLYANY,stream:STREAM,depth:INT_4,width:INT_32,verbose:BOOL_FALSE];Occasionallyitisusefultodefineaprintprocforanon-refTYPE.Inthiscase,theclientcandefineaPrintProcwhichisagivenatvdescribingthecorrespondingobject.HereisanexampleofaPrintProcwhichwillprintanobjectoftypeSystem.GreenwichMeanTimeasatime,ratherthanaLONGCARDINAL(whichisthetypeofSystem.GreenwichMeanTime).TimePrintProc:TVPrintProc={t:System.GreenwichMeanTime;t_LOOPHOLE[AMBridge.TVToLC[tv]];--getthe"time"outofthetv.stream.Put[time[t]];};AttachTVPrintProc[type:CODE[System.GreenwichMeanTime],tvPrintProc:TimePrintProc,canHandleRemote:FALSE];AttachTVPrintProc:PROC[type:RTBasic.Type,tvPrintProc:TVPrintProc,canHandleRemote:BOOL_FALSE];Moregeneralprintprocmechanismforusewithanytype.Theprocedurewillbecalledwithatvforthecorrespondingobjectandastream.IFcanHandleRemoteisTRUE,theprintprocwillalsobeinvokedonremotetvs,otherwisenot.TVPrintProc:TYPE=PROC[tv:RTBasic.TV,stream:STREAM,depth:INT_4,width:INT_32,verbose:BOOL_FALSE];SignalsandErrorsUserAborted:ERROR[abortee:REFANY_NIL,msg:ROPE_NIL];thestandarderrortoberaisedbyanapplicationtoindicatethattheuserhasaborted.ReplacesUserExec.UserAborted.EndOfStream:ERROR[stream:STREAM];attempttodoagetCharatendofstream,orattempttodoasetindexbeyondendofstream.Separateerrorforconvenience.Error:ERROR[ec:ErrorCode,stream:STREAM];ErrorCode:TYPE={NotImplementedForThisStream,asignal,ifthecorrespondingoperationdoesnotreturnavalue,e.g.SetEcho,SetLength,etc.,andnotresumable,i.e.anERROR,iftheoperationdoesreturnavalue,e.g.GetLength,IllegalBackup,attempttodoasecondbackupwithouthavingdoneanintermediategetChar,orattempttobackupacharacterotherthantheonejustread.SyntaxError,raisedbyGetBool,GetInt,GetCard,GetReal,GetRefany.16v b&tb&sb&zb&t_b&b&"g + 3 r`{vE "&(-/35d7=?1Bo^ qR N" +3-E/157b9<>CwDGF],1v Y tYsYYt3YsYYtYYs Y!|Y#Y*Zt,Y-Ys2Y3OYt7zY8VYs^t>^s>^P>^t5>^>^ ! )Y 1 9lsEt>^F->^t <s]<<t<^<r; w#%(G+C-13:<>lBNEIF~9d U "#(*6*7<^>Du7}t!U'?v 4e t4es4ej4et4es4e4etz4e4es%Q4e& 4et&4e'4es,4e-;4et1f4e2B4es64e74et94e:4e<8s@4e@4etC 4eD4e 2sT2 2t2sv2/2t2w2p .v +B t|+Bsz+B3+Bt+BX+Bs+B+B!kt$e+Bs%+B&+Bt'+B(+Bs,5+B- +Bt/+Bs1=+B2&+Bt3I+B3+Br)Z4 "n$a +K,147: ED  &(*O0F3J7]8 t r A""',/L1? 8>{@4E G#g%(A*t C r   0%+ y)eTVm$qStreamClosed,raisedbyfilestreamoperationsafterClose(exceptFlush,Reset,Close.)FileTooLong,mayberaisedbySetLengthBadIndexnegativelengthorindextoSetLength/SetIndex,ornegativeortoo-largeindextoUnsafeGetBlock/UnsafePutBlock};Signal:SIGNAL[ec:SignalCode,stream:STREAM];SignalCode:TYPE={NotImplementedForThisStream,asignal,ifthecorrespondingoperationdoesnotreturnavalue,e.g.SetEcho,SetLength,etc.,andnotresumable,i.e.anERROR,iftheoperationdoesreturnavalue,e.g.GetLength,ProcedureHasWrongType,RaisedbyImplementswhenviaisnotofthetypeofoperation.Ifresumed,effectissimplynottoimplementtheoperation,NotARefType,RaisedbyAttachRefPrintProcwhenrefTypeisnotofclassreforlist.Ifresumed,effectissimplynottoimplementtheprintproc.EmptyBuffer,raisedbyEditedStreamwhenattempttodoaneraseCharandnothingisthere.UnmatchedLeftParen,UnmatchedStringDelim,raisedbyGetRefAnyifendofstreamreachedwhilereadingalistorstring.Ifresumed,theeffectistosupplythemissingcharacter,e.g.doingGetRefAnyontherope"(ABC"willreturnthelist(ABC)iftheclientresumesthesignalUnmatchedLeftParen.Rubout,raisedbyEditedStreamwhenaDELisseen.UnprintableValue,TypeMismatch,UnknownFormatraisedbyPF.};BufferOverFlow:SIGNAL[text:REFTEXT]RETURNS[REFTEXT];usedbytextstreams,shouldreturnabiggerone,withcharacterscopiedover,orelsecanreturnsametextwithlengthresetafterhavingdonesomethingwithchartacters.Privateandsemi-privateTypesValueType:TYPE={null,atom,boolean,character,cardinal,integer,real,refAny,rope,string,text,time,tv,type};Value:TYPE=RECORD[SELECTtype:ValueTypeFROMnull=>NULL,atom=>[value:ATOM],boolean=>[value:BOOL],17tb& r `x 9 #&F).26t] r [otXr Vfg> - Tg  "/tS v OtOsOXOtOO1 s$O%eOt)O)Ov N tNsNwNtNNLSr JT= !'*-41G2|6^8> EH  &(*O0F3J7]8 r =D_"&*,].0c357j:;A-D;-5" %Wt8A r 6  ^!&(k*P,C25I:;;t37r 1 1 %*.934D68<-@_BG.;1-B% 'V+Dt,r *  ^!#&'t' #Y r % t$(v tx sv  t E sv J !&t$% s% % t* s* -t0 1 r@#S$(+. 49  @COwK +^"&*.03 p M v tTsQ tG? &~+s.3<Lv >te>sb>>t>s>r>t>sY>t > >#s*>+O>t s| d t  !s { t"   5Esa 5 5t 5 5y)eTVm$)character=>[value:CHAR],cardinal=>[value:LONGCARDINAL],integer=>[value:INT],real=>[value:REAL],refAny=>[value:REFREADONLYANY],rope=>[value:ROPE],string=>[value:LONGSTRING],text=>[value:REFREADONLYTEXT],time=>[value:GreenwichMeanTime],tv=>[value:RTBasic.TV],type=>[value:RTBasic.Type],ENDCASE];UnsafeBlock:TYPE=RECORD[base:LONGPOINTER,startIndex,stopIndexPlusOne:INT--bytes--];usedinconjunctionwithUnsafeGetBlock,UnsafePutBlockdescribedabove.Note:slotsintheStreamProcsrecordareallocatedtothoseproceduresthatareeithersobasictotheoperationofastreamthatnearlyeverystreamwillimplementthem,orelseforwhichperformanceisanissue,suchasgetBlock,getIndex,etc.OthergenericoperationssuchasBackup,PeekChar,CheckForAbort,SetEcho,EraseChar,Position,areimplementedbystoringthecorrespondingprocedureonthestreamspropertylist,andlookingitup(eachtime)thegenericoperationiscalled.Ifthestream(oritsbackingstream)doesnotsupplyanimplementation,adefaultprocedureissuppliedwhichwillaccomplishtheoperation.{16}StreamProcs:TYPE=PRIVATERECORD[getChar:PROC[self:STREAM]RETURNS[CHAR]_NIL,endOf:PROC[self:STREAM]RETURNS[BOOL]_NIL,charsAvail:PROC[self:STREAM]RETURNS[BOOL]_NIL,getBlock:PROC[self:STREAM,block:REFTEXT,startIndex:NAT,stopIndexPlusOne:NAT]RETURNS[nBytesRead:NAT]_NIL,unsafeGetBlock:UNSAFEPROC[self:STREAM,block:UnsafeBlock]RETURNS[nBytesRead:INT]_NIL,putChar:PROC[self:STREAM,char:CHAR]_NIL,putBlock:PROC[self:STREAM,block:REFREADONLYTEXT,startIndex:NAT,stopIndexPlusOne:NAT]_NIL,unsafePutBlock:PROC[self:STREAM,block:UnsafeBlock]_NIL,flush:PROC[self:STREAM]_NIL,reset:PROC[self:STREAM]_NIL,close:PROC[self:STREAM,abort:BOOL_FALSE]_NIL,getIndex:PROC[self:STREAM]RETURNS[INT]_NIL,setIndex:PROC[self:STREAM,index:INT]_NIL,otherStreamProcs:LISTOFStreamProperty_NIL,--usedforspecifyingtheimplementationofoptional,genericprocedures.SeeImplementsbelow.name:Rope.ROPE];StreamProperty:TYPE=REFStreamPropertyRecord;StreamPropertyRecord:TYPE=PRIVATERECORD[operation,via:PROCANYRETURNSANY,proc:REFANY,key:ATOM];18tb&sb&b&tkb&b&`xQsl`x%`xBt$y`x$`x^@s^0^t^5^]Zs]]t]]][mJs[m[m#t&[m&u[mY?sZY.YtkYYXzsXXt!CX!XVa[sVaVa!t$Va$VaT4OSGs$SStS SQV: sOtOOv LK tLKsLKHLKtLKsLKLKt#LKJsJ[JxtJqJ "As.J.Jr0J1 Jt5[J5Jr H0 )y 39\q D #%i+(,0g 7g:.<{@`BEG/ C3. $(+268d;'=qA Ap !%](,G1C 8$;=kB ?  $v*-h 668=@ >!!~$&+-//26|8=CE@ 5*%5s+5,5t-54s4t4t4R4sV44t 4s44t$4s$4t(4)4s*4+z4t,42j s@2j2jtc2j2js2ji2jt 2js!|2j"P2jt'2js'f2jt*2j+y2js-2j-2jt/2j0s-00tP00s0V0t0 ]0s$0%k0'Gt*F0+#0 s2020t405e0sA?0B(0tC0s/ti// s//tP/ 8/s!/"/t#/-fs|-fb-ft -f!-fs$#-f$-ft(-f)-f. s6t-f7H-ft;-f<_-f sDn-fD-ftFz-fGa-fs+t+(bs(b(bt(b}(bs(b (btK(b ((bs#(b$|(bt' (b'(bs)~(b*f(bt+(b&se& &t&&s&&t& &s$&%&'.t1&2\& s9M&:6&t;&<&s% tV% >% s% % t% #^sE#^#^th#^#^s#^o#^t##^$v#^( 1!s2#^3#^t4#^!s!!t!!s!$!tO!6!s! !t!!SsSvStSTSsXSSt"S SsS St!SstusytC s"8"t%s'Z(t*+s-l.Ut/xs8t[sats t!Ht&es&t()s+H,1t-THs HHt/HHsH5Ht`H =Hs$H$Ht&H'tHs)H)Ht+ Hs?ktj1 (>s)*t+r,--.*1;3c 9; Eet '" *tDGsDDtv 9 ta9s^99t9s9n9tK99v t s P t s { %3t*! * 1s3 4d 7I:B@4tB C s 5t 5 5s 5 5tu 5 5y)eTVm$Characterconstants.Includedforconvenience.CR:CHAR=Ascii.CR;SP:CHAR=Ascii.SP;TAB:CHAR=Ascii.TAB;LF:CHAR=Ascii.LF;BS:CHAR=Ascii.BS;ControlA:CHAR=Ascii.ControlA;ControlX:CHAR=Ascii.ControlX;FF:CHAR=Ascii.FF;NUL:CHAR=Ascii.NUL;ESC:CHAR=Ascii.ESC;DEL:CHAR=Ascii.DEL;BEL:CHAR=Ascii.BEL;MiscellaneousBackSlashChar:PROC[char:CHAR,stream:STREAM_NIL]RETURNS[CHAR];interpreters\conventions,e.g.maps\ntoCR,\ttoTAB,etc.RaisesSyntaxErrorif\notfollowedbyacceptablecharacter.IFcharisin['0..9],thenstreammustbesupplied,orelsesyntaxerror.Ifstreamissupplied,twomorecharactersareread.Ifthesearedigits,returnscorrespondingcharacter,otherwise,raisesSyntaxError.Zone:PRIVATEZONE;--prefixedzoneusedforstoringstreamdata,streamprocs,etc.END.Convertingfrom3.5ThefollowingaresomesuggestionsabouthowtoconvertaprogramusingIO.GetRopeorIO.GetTokentothenewschemeofthings.Thesesuggestionsshouldcoverabout95%ofthecases.LetusconsiderGetTokenfirst.Aold-stylecalloftheforms.GetToken[],whichdefaultsthesecondargument,canstaythesame.ButyoumightwanttoconsiderusingGetCedarTokeninstead,especiallyifwhatyouaredoingisreadingmesa:GetCedarTokenwilldomoreCedar-likethingsforrealnumbers,quotedliterals,quotedtext,andthelike.GetRopeisonlyalittlemorecomplicated.Anold-stylecalloftheforms.GetRope[],whichdefaultsthesecondandthirdarguments,canbereplacedbythenewcalls.GetToken[IDProc].Notethatthenewcalls.GetToken[]wouldalsoprobablydowhatyouwant,theonlydifferencebeinginthetreatmentofbreakcharacters:forexample,theolds.GetRope[]wouldread@fooasasingletoken,whilethenews.GetToken[]wouldreaditastwoseparatetokens.Similarly,/indigo/cedar/top/io.dfwouldbereadas8tokensbythenews.GetToken[],butasonlyonetokenbytheolds.GetRope[]andthenews.GetToken[IDProc].Allthreeofthesehavethesameeffectifyourdesiredtokensarealwaysseparatedbywhitespace.Beware!IfyouuseGetRope,youcannotdependoncompileerrormessagesalonetotellyouwherechangeshavetobemade.ThenewGetRopemeanssomethingquitedifferentfromtheoldGetRope,butanycalltotheoldGetRopethatdefaultsthesecondandthirdargumentswillstilllookOKtothecompilerasacallonthenewGetRope.ClientsoftheoldGetRopewerejustparsingsomerandominputintothingsseparatedbywhitespace.AclientofthenewGetRopeshouldbeintheprocessofparsingtheinputstreamasasequenceofmesatokens.SuchaclientcallsthenewGetRopewhensheexpectsaropeliteraltobethenextthinginthe19p a R" w+1as ^t ^s^e^t\^A^s^Q^t%^s \t D\sB\ \t\\s.\\tu\s [OtC[Os@[O [Ot[O[Os-[O[Ots[Os Yt oYsmY8Yt/YYsZYYtYs Wt UWsSWWtWWs@WWtW VWsVW_VWtWVWLfp HC v D tDsDDtD DsDaDt D!Ds&D'TDt+Ds-uD.^Dt/Ds0hD1U z  $' v ;t ;s ;;jt;r;; N#w&(-.149I=*s 7t s7p 3 K8t 0B; "%(*/0679 A . LZH!'"'P+Q 27:>AC=E +J}MR !'")+f-1, 9=B )bo<#&)M-E02P7;s ' q!%'%,0 :=`?f &T "'F,0368 #\vc &)?.1Y35q8 @ !]\ &(*024p7^9 Gtb #'J*/15L8;>A1 I m '*/2E4 !$&',$. 03m ;>u@#C= k !$'4^6::;?|BE" q8[ %+2-.0 ![!&*,2-5;z?/@C< y[ !$n'\-O186;AeD :2!?#),j138;@>EV +qCP  !$n&u(+2788;Q=C qE #|'-/3o89=M?Af ?0="#(*.345;=A 5Dn.=#~'3).|/268p:a<?CdEy)eTVm$Ninputstream,andthecalltoGetRopeeitherreturnsthecorrespondingropeorraisesanerror.Thus,allcallstotheoldGetRopemustbechangedtoGetTokenasdescribedinthepreviousparagraph,andyoumustsearchyourprogramtofindthemall.IfyouhavedefinedyourownIO.BreakProcsforusewithGetToken,thefollowingrecipeshouldwork:changealloftheStopAndPutBackCharandStopAndTossChartosepr,StopAndIncludeChartobreak,andKeepGoingtoother.IfyouhavedefinedyourownIO.BreakProcsforusewithGetRope,youshouldchangeKeepGoingtootherandeverythingelsetosepr,andthenuseGetTokeninplaceofGetRope.However,youmightwanttorewriteintermsofGetSequenceinstead.20t b&{CZ$(s-&/ 8|;=pA/C  `T"%x'i,.56<>@ ^ b #)+3."1 [ 6}} '*,/68>C Yn^w)"+7E8S@C VN&l(+.q 5579<?B T\ X &)-02788<>j SDy)eTTVm$ TIMESROMAN HELVETICA TIMESROMAN TIMESROMANY TIMESROMAN TIMESROMANLAUREL TIMESROMAN TIMESROMAN TIMESROMAN TIMESROMANY0  - : F R _ h %r ^ )  3j/io.mesa 9-Mar-83 22:57:38