8-Sep-81 Yet Another Extension x write(field,xval:vl); end; Posit(screen,field,vx,vy); init(field); write(field,name:nl,' (' ,fx:l,')'); Posit(screen,field,nx,ny); end: get (table) ; end: end; Dump(output,screen); end; begin { MoneyMarketIII } InlO:=ln(10.0); { Determine filnum } dread(table,filnum,filcon); connect (data,filcon.name) " external is standard, w'r • .i not connect? }: reset(data) { Requires random-I/O ability in run-time environment ); { Po"j.tion datafile and determine page} FiIIScreen(output,table,data,filnum,page,ScreenHeight,ScreenWidth); { Other processing } end. ~!:~~t:.~inU~!l~ The main point of this essay (whenever it pretended to have one) has been that <strong>Pascal</strong> has always had string-handling ability and that the addition of a few functions could provide enough improvement to obviate any need for a heavyweight boxing match to decide which dynamic array description method should be used. However, the example program is in many ways redundant, since the same kinds of code sequences appear repeatedly. For this reason the following suggested list of string functions i8 proposed. Implementing them in assembly would remove the restriction that the files must be of a specific type. The "type" File, as used below, reflects this generic capability, available only to intrinsic procedures. procedure Append(var output,input:File); begin reset(input) ; while NOT eof(input) do begin write(output,inputt); get(input); endi t:!nd; procedure Copy (var output,input:File); begin i.nit(output); Append(output,input); end; 8-Sep-Sl Yet Another Extension procedure Posit{var output,input:File; sequence: Integer) : begin seek(output,sequence); Append(output,input): end; procedure Switch(vat output,input:File): begi" Copy {output, input) ; init(input) ! Actually, since the internal pointers are being switched, the input file would be left undefined (closed). } end; procedure Extract(var input,output:File; loc,leng:Integer); var x:lntegeri begin seek(input,loc) ; init(output): for x:=l to leng do begin write(output,inputt); get (input) ; end; end; procedure Insert(var output,input:File; sequence: Integer) ; var temp: File; x : Integer: begin Extract (output,temp,O,sequence) ; Append(temp,input); while NOT eof(output) do begin write(temp,outputt); get (output) ; end; copy(output,temp): end; function Compare (var left,right:File) :1•• 3; label 1; begin reset(left) ; reset (right) ; 1: if eof(left) then compare:=3-ord(eof(right» else if eof(right) then COmpare:=l+ord(eof(left» else if lefttrightt then Compare:=1+2*ord(leftt
8-Sep-Sl 1: 2: Yet Another Extension Function Locate(var parent,search:File) :Integer; ~ Pr~-assertions: parent.M=Directj parent.Pos is starting point. } ~ Post-assertions: parent.Pos=Locate+length(search) , t Locate is assigned the parent sequence number of the first elef!tent of search (starting the search from the input va!ue of parent.Pos).. If the search file cannot be found in parent, Lcca~::;'? is returned as length(parent}. This defini~ion avoids S9€cia: case handling both within Locate and in the calling (;OCC. Conpare this simplicity to the definition and use of DEC's BASIC ins':"/pos function! } label 1,2; var 10calroot:Integer; begin localroot:=pos(parent) ; while localroot