%include "inc:util.imp"
%include "inc:dict.imp"

{ ripped-off from cli }
%routine define symbol(%string(255)symbol,value)
%integer stag,vtag
  stag = defname(symbol,comdict,8)
  %if stag=0 %start
    printstring("*Command dict full"); newline; %return
  %finish
  vtag = defname(value,fildict,8)
  %if vtag=0 %start
    printstring("*File dict full"); newline; %return
  %finish
  %if stag<0 %start
    stag = stag<<1>>1
!   printstring(symbol.": ".value." replaces ")
!   transname(integer(stag),symbol); printstring(symbol); newline
  %finish
  integer(stag) = vtag<<1>>1
%end

%begin
   %integer i, chunk
   %string (255) defstr

   i = heapget(4)
   chunk = (addr(i) - i - stoi(cliparam))//(48*1024)
   defstr = "CPLOG:PROLOG -H".itos(chunk * 16, 0)." -G".itos(chunk * 16, 0)
   defstr = defstr." -L".itos(chunk * 8, 0)." -T".itos(chunk * 3, 0)
   defstr = defstr." -A".itos(chunk * 4, 0)." -X".itos(chunk, 0)
   define symbol("PROLOG", defstr)
%endofprogram
