perm filename UNIQUE.SIM[SIM,SYS] blob sn#460340 filedate 1979-07-20 generic text, type T, neo UTF8
OPTIONS(/E/C/-Q/-A/-I/-D);
! UNIQUE will return increasing integer numbers in the interval
! [0,34 356 959 999] occurring only once per (approx) 20 year cycle.
! The returned value will increase with one each 0.02 second.
;
EXTERNAL INTEGER PROCEDURE dayno;
EXTERNAL TEXT PROCEDURE today;
EXTERNAL REAL PROCEDURE clocktime;
INTEGER PROCEDURE unique;
BEGIN   INTEGER xdayno,year;

year:= today.Getint;
xdayno:= (year-1976)*365 +		! Calculate day no. since 76-01-01;
	dayno-1 + (year-1973)//4;	! Add no. of leapdays for the
					! years 1976,1977,...(y-1) ;
					! ticks [0,50*60*60*24] ;
					!  =	[0, 4 320 000 ] ;
! unique:= 4 320 000 *xdayno + ticks;
! Restart 7953 days after 76-01-01 = 97-10-10 ;
unique:= 50*( 86 400*Mod(xdayno,7953) + clocktime);

END of unique;