perm filename REFORM.SAI[USE,CSR] blob sn#238556 filedate 1976-09-27 generic text, type C, neo UTF8
COMMENT ⊗   VALID 00003 PAGES
C REC  PAGE   DESCRIPTION
C00001 00001
C00002 00002	begin comment reformat address file
C00004 00003	output phase
C00005 ENDMK
C⊗;
begin comment reformat address file;
integer c1,c2,brch,ct,eof,flg,n,i,j,h,s;
string st,ent;
integer array key[0:1999];
string array ntry[0:1999];
setbreak(1,'12&'14,null,"IA");
open(c1←getchan,"DSK",0,2,0,ct,brch,eof);
open(c2←getchan,"DSK",0,0,2,ct,brch,eof);
ct←100;
lookup(c1,"addfil.dsk",flg);
enter(c2,"addfil.new",flg);
st←input(c1,1);
n←0;
do begin if st="*" and not equ(st[1 to 2],"*#") then
begin ent←st;n←n+1;
key[n]←cvasc(st[22 to 26]);
for i←1 step 1 until 5 do
	begin st←input(c1,1);
	if length(st)>2 then ent←ent&st;
	end;
ntry[n]←ent;
end;
st←input(c1,1);
end until eof;
h←1093;
for s←1 step 1 until 6 do
begin h←(h-1)/3;
for j←1+h step 1 until n do
if key[j-h]>key[j] then
	begin i←j-h; flg←key[j]; ent←ntry[j];
	do begin key[i+h]←key[i];ntry[i+h]←ntry[i];i←i-h;end
	until i≤0 or key[i]≤flg;
	key[i+h]←flg;ntry[i+h]←ent;
	end;
end;
for i←2 step 1 until n do if key[i-1]=key[i] then
outstr('15&'12&"duplicate hashes"&ntry[i-1]&ntry[i]);
comment output phase;
setformat(-5,0);
for i←1 step 1 until n do
begin if i mod 10 = 1 then
	begin ent←'14; for j←0 step 1 until 9 do if i+j≤n then
	ent←ent&ntry[i+j][21 to 26]&",";
	out(c2,ent&'15&'12);
	end;
out(c2,ntry[i][1 to 26]&cvs(i)&ntry[i][27 to 1000]);
end;
close(c1);close(c2);
end;