unit HTML_Sdk;
interface
uses SdkKrnl;
Function tex(s:longint):string;
Procedure HTML_file(fn:string;sdk:TSdk;ns:word);
Procedure OpenIni(fn:string);
Function Exist(fn:string):boolean;
var sep:array[0..8]of record bg,ed:string;end;
implementation
uses dos, strings, windos;
type fchar = file of char;
var i,j,k:integer;
f:fchar;
simb:string;
Function Exist(fn:string):boolean;
var sr:TSearchRec; p: pchar;
begin
p:=@fn; inc(p);
FindFirst(p,$3f,sr);if doserror=0 then Exist:=true else exist:=false;
end;
Function tex(s:longint):string;
var c:string;
begin
str(s,c);tex:=c;
end;
Function UpperCase(s: string):string;
var r: string; i: integer;
begin
r:='';
for i:=1 to length(s) do r := r + UpCase(s[i]);
UpperCase := r;
end;
Procedure append(var f: fchar);
begin
{$I-}
reset(f);
if(IOResult<>0) then rewrite(f);
seek(f, filesize(f));
{$I+}
end;
Procedure HTML_file;
Procedure WF(s:string);
var i:integer;
begin
for i:=1 to length(s) do write(f,s[i]);
end;
begin
if fn='' then fn:='Sudoku.htm';
if UpperCase(Copy(fn,length(fn)-3,3))<>'HTM'then fn:=fn+'.htm';
assign(f,fn);append(f);
with sdk do begin
WF(sep[7].ed+sep[0].bg+sep[7].ed);
if ns >0 then wf(tex(ns)+'
'+sep[7].ed);
WF(sep[1].bg);
for i:=1 to nn do begin
if(i-1)mod n=0 then WF(sep[2].bg);
WF(sep[3].bg);
WF(sep[4].bg);
for j:=1 to nn do begin
if(j-1)mod n=0 then WF(sep[5].bg);
WF(sep[6].bg);
simb:=HexChr( GetXY( px(i,j), py(i,j) ) );
if(simb=' ')then wf(sep[7].bg)else wf(simb);
WF(sep[6].ed);
if(j)mod n=0 then WF(sep[5].ed);
end;
WF(sep[4].ed);
WF(sep[3].ed);
if(i)mod n=0 then WF(sep[2].ed);
end;
WF(sep[1].ed);
WF(sep[0].ed);
end;
close(f);
end;
Procedure OpenIni(fn:string);
var f:text; s:string;
begin
if fn='' then fn:='HTML.ini';
if Exist(fn) then begin
assign(f,fn);reset(f);
i:=0;
while not eof(f)and(i<8)do begin
readln(f,s);
if s>' 'then sep[i].bg:=s;
readln(f,s);
if s>' 'then sep[i].ed:=s;
readln(f);
inc(i);
end;
close(f);
end;
end;
begin
for i:=0 to 8 do with sep[i] do begin bg:='';ed:='';end;
sep[0].bg:='
' ; sep[0].ed:='
' ; sep[1].bg:='