program pause;

{
Pause source file, use HSPascal v1.20 and WB3.1 units to compile.

Sorry for not commenting the source properly, see what you can make
of it anyway.

Author Nicolai Jensen 17-May-1995
}

Uses exec, Paus, crt, AmigaDOS, init;
const 
	Version = '$VER: Pause 38.0 (17.05.95)'#0;
var
	Ver			: string[29];
	DummyBool	: boolean;
	Break		: longint;
	OldExitProc : pointer;	{ Exit Handler }

procedure Slut_Prog;
{ Procedure to  Finish nicely no matter how the program exits }
begin
	ExitProc := OldExitProc;	
	ClosePauseCatalog;
	CloseLibs;
end;


procedure HandleBreak;
var
		ProgNam : Strptr;
        pDummePointer	: strptr;               
begin
	DummyBool:=GetProgramName(ProgNam,128);
	writeln;
	pDummePointer := ProgNam;
	DummyBool := Printfault(ERROR_BREAK, pDummePointer);
	halt(ERROR_BREAK);
end;


Begin
	OldExitProc := exitproc;	{ These 2 lines makes Slut_Prog to an exit-routine, }
	ExitProc := @Slut_Prog;		{ which is executed when/if the program is interrupted }
	{
		In HSPascal version strings has to be active parts of the code... (AFAIK)
		That is why the following line is required in this program
	}
	Ver:=Version;

	DummyBool:=OpenLibs;
	OpenPauseCatalog(nil,nil);
	write(GetString(Long(PauseText))); { Pause text is 'Pause... hit <ENTER> to continue' }
	repeat
		Break := checksignal(SIGBREAKF_CTRL_C);
		if Break <> 0 then
			HandleBreak;
	until readkey=#13;
	writeln;
end.
