Pascal News
Pascal News
Pascal News
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
8-Sep-81<br />
Yet Another Extension<br />
x write(field,xval:vl);<br />
end;<br />
Posit(screen,field,vx,vy);<br />
init(field);<br />
write(field,name:nl,' (' ,fx:l,')');<br />
Posit(screen,field,nx,ny);<br />
end:<br />
get (table) ;<br />
end:<br />
end;<br />
Dump(output,screen);<br />
end;<br />
begin { MoneyMarketIII }<br />
InlO:=ln(10.0);<br />
{ Determine filnum }<br />
dread(table,filnum,filcon);<br />
connect (data,filcon.name) " external is standard, w'r • .i not connect? }:<br />
reset(data) { Requires random-I/O ability in run-time environment );<br />
{ Po"j.tion datafile and determine page}<br />
FiIIScreen(output,table,data,filnum,page,ScreenHeight,ScreenWidth);<br />
{ Other processing }<br />
end.<br />
~!:~~t:.~inU~!l~<br />
The main point of this essay (whenever it pretended to have one)<br />
has been that <strong>Pascal</strong> has always had string-handling ability and that<br />
the addition of a few functions could provide enough improvement to<br />
obviate any need for a heavyweight boxing match to decide which dynamic<br />
array description method should be used. However, the example program<br />
is in many ways redundant, since the same kinds of code sequences<br />
appear repeatedly. For this reason the following suggested list of<br />
string functions i8 proposed. Implementing them in assembly would<br />
remove the restriction that the files must be of a specific type.<br />
The "type" File, as used below, reflects this generic capability,<br />
available only to intrinsic procedures.<br />
procedure Append(var output,input:File);<br />
begin<br />
reset(input) ;<br />
while NOT eof(input) do begin<br />
write(output,inputt);<br />
get(input);<br />
endi<br />
t:!nd;<br />
procedure Copy (var output,input:File);<br />
begin<br />
i.nit(output);<br />
Append(output,input);<br />
end;<br />
8-Sep-Sl<br />
Yet Another Extension<br />
procedure Posit{var output,input:File; sequence: Integer) :<br />
begin<br />
seek(output,sequence);<br />
Append(output,input):<br />
end;<br />
procedure Switch(vat output,input:File):<br />
begi"<br />
Copy {output, input) ;<br />
init(input) ! Actually, since the internal pointers are being<br />
switched, the input file would be left undefined (closed). }<br />
end;<br />
procedure Extract(var input,output:File; loc,leng:Integer);<br />
var x:lntegeri<br />
begin<br />
seek(input,loc) ;<br />
init(output):<br />
for x:=l to leng do begin<br />
write(output,inputt);<br />
get (input) ;<br />
end;<br />
end;<br />
procedure Insert(var output,input:File; sequence: Integer) ;<br />
var<br />
temp: File;<br />
x : Integer:<br />
begin<br />
Extract (output,temp,O,sequence) ;<br />
Append(temp,input);<br />
while NOT eof(output) do begin<br />
write(temp,outputt);<br />
get (output) ;<br />
end;<br />
copy(output,temp):<br />
end;<br />
function Compare (var left,right:File) :1•• 3;<br />
label 1;<br />
begin<br />
reset(left) ;<br />
reset (right) ;<br />
1:<br />
if eof(left) then compare:=3-ord(eof(right»<br />
else if eof(right) then COmpare:=l+ord(eof(left»<br />
else if lefttrightt then Compare:=1+2*ord(leftt