program install;
uses crt,dos,skashit,control,menusys,little,gensubs;
{:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::}
Procedure iEditorScrn; External; {$L EDITOR.OBJ}
Procedure iSelectionScrn; External; {$L SELECT.OBJ}
Procedure iProgressScrn; External; {$L PROGRESS.OBJ}
{:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::}
var iInstalled : boolean;
Function DosShell(command:String):Integer;
Var
OldHeapEnd,
NewHeapEnd: Word;
Error:Integer;
Begin
Error:=0;
If MemAvail<$1000 then Error:=8;
If Error=0 then Begin
NewHeapEnd:=Seg(HeapPtr^)-PrefixSeg;
OldHeapEnd:=Seg(HeapEnd^)-PrefixSeg;
asm
mov ah,4Ah
mov bx,NewHeapEnd
mov es,PrefixSeg
Int 21h
jnc @EXIT
mov Error,ax
@EXIT:
end; {asm}
If Error=0 then begin
SwapVectors;
Exec(GetEnv('COMSPEC'),command);
SwapVectors;
asm
mov ah,4Ah
mov bx,OldHeapEnd
mov es,PrefixSeg
Int 21h
jnc @EXIT
mov Error,ax
@EXIT:
end; {asm}
end; {If}
end; {If}
DosShell:=Error;
end; {Function}
Procedure iInstallProc;
var iInstallDir : string;
Procedure iDisplayLog;
var iLogFile : text;
iStr : string;
begin
textAttr := 7;
if (exist('install.log')=false) then exit;
assign(iLogFile,'install.log');
reset(iLogFile);
repeat readLn(iLogFile,iStr); writeLn(iStr); until (eof(iLogFile)=true);
close(iLogFile);
textAttr := 15;
end;
Procedure iDirectWrite(x,y : byte; str : string);
var iCount : byte;
begin
for iCount := 1 to length(str) do
begin
mem[$b800:(pred(y)*160)+((pred(x)+pred(iCount))*2)] := ord(str[iCount]);
mem[$b800:(pred(y)*160)+((pred(x)+pred(iCount))*2)+1] := 7;
end;
end;
Procedure iUpdateProgress(str : string);
begin
iDirectWrite(5,22,tab(str,70));
end;
Function iDirExist (dir : string) : boolean;
var fHandle : file;
wAttr : word;
begin
while (dir[byte(Dir[0])]='\') do
dec(dir[0]);
dir := dir+'\.';
assign(fHandle,dir);
getFAttr(fHandle,wAttr);
iDirExist := ((wAttr and $10)=$10);
iInstallDir := dir;
end;
begin
window(1,10,80,19);
iInstallDir := inputStr(37,15,15,39,'c:\infusion\');
if (iInstallDir<>'') then
begin
savePal; fadeWhite; move(@iProgressScrn^,mem[$b800:0],4000);
unFade;
iUpdateProgress('checking if ('+iInstallDir+') exists...');
if (iDirExist(iInstallDir)=true) then
skaWrite('|15|B0%% directory exists, beginning unpacking!|CR') else
begin
skaWrite('|15|B0== directory does not exist, creating and beginning unpacking!');
while (iInstallDir[byte(iInstallDir[0])]='\') do dec(iInstallDir[0]);
iInstallDir := iInstallDir+'\.';
{$i-} mkDir(iInstallDir); {$i+}
if (ioResult<>0) then
begin skaWrite('|15|B0%% error, could not create! halting!|CR'); clrScr; halt(5) end;
end;
iUpdateProgress('unpacking and installing infusion...');
dosShell('/c pkunzip.exe -d install.dat '+iInstallDir+' > install.log');
iDisplayLog;
skaWrite('|15|B0== installation and unpacking complete!|CR');
iUpdateProgress('running infuinit.exe to initialize your new infusion system...');
chDir(iInstallDir); dosShell('/c infuinit.exe > install.log');
iDisplayLog;
skaWrite('|15|B0%% infusion initialized succesfully!|CR');
iUpdateProgress('returning to main menu...');
move(@iSelectionScrn^,mem[$b800:0],4000);
window(1,1,80,25); iInstalled := true;
end;
end;
{:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::}
Procedure iNotAvailable(num : byte);
begin
gotoXY(35,20); if (num=0) then skaWrite('|B0|15 u p g r a d e n o t a v a i l a b l e ') else
skaWrite('|B0|15 e d i t o r i a l n o t a v a i l a b l e ');
readKey;
gotoXY(35,20); for num := 35 to 80 do write(#32);
end;
{:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::}
Procedure iSelectionProc;
var iSelection : byte;
iDone : boolean;
begin
if (exist('pkunzip.exe')=false) or (exist('install.dat')=false) then
begin
clrScr;
skaWrite('|15|B0error, archive incomplete! halting!|CR');
halt(5);
end;
sInitMenuSys(true);
sBarData^.BarShown := 4;
sBarData^.BarXPos := 11;
sBarData^.BarYPos := 13;
sAddMenuSelection(1,'|15>> install! ','|07 install ');
sAddMenuSelection(2,'|15>> upgrade! ','|07 upgrade ');
sAddMenuSelection(3,'|15>> editorial! ','|07 editorial ');
sAddMenuSelection(4,'|15>> abort ','|07 abort ');
iDone := false;
repeat iSelection := sMenuSelection;
case iSelection of
0 : iDone := true;
1 : iInstallProc;
2 : iNotAvailable(0);
3 : iNotAvailable(1);
4 : iDone := true;
end;
until (iDone=true);
sInitMenuSys(false);
clrScr;
if (iInstalled=true) then
skaWrite('|15>> |07Infusion succesfully installed. Now run INF.BAT!|CR');
end;
{:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::}
begin
move(@iSelectionScrn^,mem[$b800:0],4000);
iSelectionProc;
cursor_on;
end.