[INHERIT('SYS$LIBRARY:STARLET')] PROGRAM LEAVEEXE(INPUT,OUTPUT);
	TYPE
		SYS_TIME =	RECORD
				I,J : INTEGER;
				END;
		VARY = VARYING[80] OF CHAR;
		PAS_WORD = [WORD] -32768..32767;
	VAR
		ASCII_TIME 	   : PACKED ARRAY [1..255] OF CHAR;
		ALARM_MSG  	   : PACKED ARRAY [1..80] OF CHAR;
		BINARY_TIME 	   : SYS_TIME;
		ALARM_TIME 	   : VARY;
		ALARM_LOG  	   : VARY;
		TIME_LEN , MSG_LEN : PAS_WORD;
		I 		   : INTEGER;

		[EXTERNAL] PROCEDURE RING_BELL ; EXTERN;

	BEGIN
		FOR I := 1 TO 255 DO
			ASCII_TIME[I] := ' ';
		ALARM_TIME := 'ALARM_TIME';
		IF NOT ODD ( $TRNLOG ( ALARM_TIME, TIME_LEN, ASCII_TIME ))
		THEN
			BEGIN
			WRITELN ( 'Could not find logical name.');
			HALT;
			END;{If}
		FOR I := 1 TO 64 DO
			ALARM_MSG[I] := ' ';
		ALARM_LOG := 'ALARM_LOG';
		IF NOT ODD ( $TRNLOG ( ALARM_LOG, MSG_LEN ,ALARM_MSG ))
		THEN
			BEGIN
			WRITELN ( 'Could not find msg logical name.');
			HALT;
			END;{If}
	IF NOT ODD ($BINTIM ( ASCII_TIME, BINARY_TIME))
	THEN
		BEGIN
		WRITELN('Something wrong with the time');
		HALT;
		END;{If}
	IF ODD ($SCHDWK ( DAYTIM := BINARY_TIME))
	THEN
		$HIBER 
	ELSE
		BEGIN
		WRITELN ( 'Cannot schedule alarm' );
		WRITELN ( 'Process ending immediately');
		END;{If}
	RING_BELL;
	WRITELN(ALARM_MSG);
	END.{Leaveexe}
