%constinteger max base commands=12 %conststring(255)%array base commands(1:max base commands)=%C "alias","remove","monitor","stop","quit","launch","broadcast","tell", "autoattack","surrender","dump","resources" !"B","C","D","E","F","G","H","I","J","K","AL","LI","RE","ST" %recordformat com form (%string(80)comstr,%byteinteger base,type) %constinteger max possible commands=20 %ownrecord(com form)%array commands(1:max possible commands) %owninteger max commands=0 %routine sort(%record(com form)%arrayname r,%integer lo,hi) !%routine sort(%stringarrayname r,%integer lo,hi) %integer i,j,k,l,n %record(com form)x !%string(255)x l=lo-1 n=hi !%while n 1<<((32- shz{shift while not zero}(hi-l-1))&31) !n contains smallest +ve integral power of 2 not less that hi-lo+1 *lss_n;*isb_l;*isb_1;*shz_%tos;*lb_32;*sbb_%tos;*lss_1;*rot_%b;*st_n %cycle n=n//2 %returnif n=0 i=l %cycle i=i+1 j=i+n %exitif j>hi k=i %while r(j)_comstr0 %cycle pos=(lo+hi)//2 %result=pos %if tab(pos)_comstr=wanted ! %result=pos %if tab(pos)=wanted %if tab(pos)_comstr0 %start printstring(s." is command number ") write(i,1) %finishelse printstring(s." not known") newline %if i=1 %start{alias} readstring(c);readstring(al) add alias(c,al) %finish %if i=2 %start{remove} readstring(al) remove alias(al) %finish %if i=3 %start{list} %for i=1,1,max commands %cycle write(i,3) printstring(" ".commands(i)_comstr) write(commands(i)_base,5) write(commands(i)_type,5) newline %repeat %finish %if i=4 %thenreturn %repeat %end %endoffile