PARSE SOURCE TOS .
SELECT
WHEN TOS == "DOS" THEN VRX = "PCDOS REXX"
WHEN TOS == "MSDOS" THEN VRX = "DOS BREXX"
WHEN TOS == "PCDOS" THEN VRX = "DOS PREXX"
WHEN TOS == "UNIX" THEN VRX = "Linux REGINA"
WHEN TOS == "WIN32" THEN VRX = "Wine REGINA"
WHEN TOS == "WindowsNT" THEN VRX = "Wine ooREXX"
WHEN TOS == "LINUX" THEN VRX = "Linux ooREXX"
OTHERWISE VRX = "Who Knows?"
END
SELECT
WHEN TOS == "DOS" THEN NOP
WHEN TOS == "MSDOS" THEN CALL IMPORT '\U\REXX\BREXX\CONIO.R'
WHEN TOS == "PCDOS" THEN NOP
WHEN TOS == "UNIX" THEN CALL rxfuncadd 'SYSGETKEY','rexxutil','sysgetkey'
WHEN TOS == "WIN32" | TOS = "WindowsNT" THEN DO
CALL rxfuncadd 'SYSGETKEY','RexxUtil','sysgetkey';END
OTHERWISE NOP
END
ESC = "1B"x||"[" ;
AC = 12 ;
DC.0 = 14 ;
DC.1 = "X" ;
DC.2 = "N" ;
DC.3 = "#" ;
DC.4 = "@" ;
DC.5 = X2C("DB") ;
DC.6 = X2C("DF") ;
DC.7 = X2C("DD") ;
DC.8 = X2C("B0") ;
DC.9 = X2C("B1") ;
DC.10 = X2C("B2") ;
DC.11 = X2C("B3") ;
DC.12 = X2C("7C") ;
DC.13 = X2C("AF") ;
DC.14 = X2C("7F") ;
DT = 1 ;
DCC = 1 ;
CSS = 10 ;
R = 8 ;
HLP = 2 ;
HRP = HLP + CSS ;
CLP = HRP + CSS ;
MLP = CLP + CSS ;
MRP = MLP + CSS ;
CRP = MRP + CSS ;
SLP = CRP + CSS ;
SRP = SLP + CSS ;
CP.0 = "XXXXXXXXXX XXXX XXXX XXXX XXXX XXXXXXXXXX"
CP.1 = " XXX XX XX XX XX XX XXXXXXX"
CP.2 = "XXXXXXXXXX XX XXXXXXXXXXXX XX XXXXXXXXXX"
CP.3 = "XXXXXXXXXX XX XXXXXXXXXX XXXX XXXXXXXXXX"
CP.4 = "XX XXXX XXXX XXXXXXXXXX XX XX XX"
CP.5 = "XXXXXXXXXX XX XXXXXXXX XXXX XXXXXXXXXX"
CP.6 = "XXXXXXXXXX XXXX XXXXXXXXXX XXXX XXXXXXXXXX"
CP.7 = "XXXXXXXXXX XX XX XX XX XX XX"
CP.8 = "XXXXXXXXXX XXXX XXXXXXXXXXXX XXXX XXXXXXXXXX"
CP.9 = "XXXXXXXXXX XXXX XXXXXXXXXX XXXX XXXXXXXXXX"
CP.10 = " XX XX "
GOTO1:
CALL ASAY 0,0,0,"" ;
CALL ASAY 1,1,AC,CENTER("REXX Digital Clock Using "VRX,80," ")
CALL ASAY 22,1,AC,CENTER(DATE(),80," ")
CALL ASAY 24,1,8,CENTER("Ctrl Z to Exit, (N)ext/(P)rior Mode = "DCC,80," ")
CALL ASAY 24,38,15,"N";CALL ASAY 24,45,15,"P" ;
GOTO2:
CALL ASAY 24,59,13,DCC||" " ;
OHL = " "; OHR = " " ;
OML = " "; OMR = " " ;
OSL = " "; OSR = " " ;
H = "00:00:00" ;
CCN = 0 ;
CALL BUILDNUMBER 10
DO X = 1 TO 7
CALL ASAY R+X-1,CLP,AC,CL.X ;
CALL ASAY R+X-1,CRP,AC,CL.X ;
END
DO FOREVER
D = TIME('N') ;
IF D == "00:00:01" THEN SIGNAL GOTO1 ;
IF D == H THEN ITERATE ;
CALL BUILDTIMEDISPLAY
TKEY = ""
SELECT
WHEN TOS == "DOS" THEN DO;IF CHARS('') <> 0 THEN TKEY = RXGETKEY('NOECHO');END
WHEN TOS == "MSDOS" THEN DO;IF KBHIT() <> 0 THEN TKEY = GETCHE();END
WHEN TOS == "PCDOS" THEN DO;TKEY = INKEY("NOWAIT");END
WHEN TOS == "UNIX" THEN DO;TKEY = SYSGETKEY('n','.001');END
WHEN TOS == "WIN32" THEN DO;TKEY = SYSGETKEY('n','.001');END
WHEN TOS == "WindowsNT" THEN DO;IF CHARS('') <> 0 THEN TKEY = SYSGETKEY('NOECHO');END
OTHERWISE ITERATE
END
IF (TKEY = "" | TKEY = " ") THEN ITERATE
SELECT
WHEN TKEY == "1A"x THEN SIGNAL EEXIT ;
WHEN TRANSLATE(TKEY) == "N" THEN DO ;
DCC = DCC + 1
IF DCC > DC.0 THEN DCC = 1
DT = DC.DCC
SIGNAL GOTO2; END
WHEN TRANSLATE(TKEY) == "P" THEN DO ;
DCC = DCC - 1
IF DCC < 1 THEN DCC = DC.0
DT = DC.DCC
SIGNAL GOTO2; END
OTHERWISE NOP
END
END
EEXIT:
CALL ASAY 0,0,7,""
EXIT
BUILDTIMEDISPLAY:
PARSE VALUE D WITH HL 2 HR 3 CX 4 ML 5 MR 6 CX 7 SL 8 SR
SELECT
WHEN SR <> OSR THEN DO; T = SR; C = SRP; OSR = SR; END;
WHEN SL <> OSL THEN DO; T = SL; C = SLP; OSL = SL; END;
WHEN MR <> OMR THEN DO; T = MR; C = MRP; OMR = MR; END;
WHEN ML <> OML THEN DO; T = ML; C = MLP; OML = ML; END;
WHEN HR <> OHR THEN DO; T = HR; C = HRP; OHR = HR; END;
WHEN HL <> OHL THEN DO; T = HL; C = HLP; OHL = HL; END;
OTHERWISE RETURN
END
CALL BUILDNUMBER T
CALL DISPLAYNUMBER
RETURN
DISPLAYNUMBER:
CCN = CCN + 1 ;
IF CCN == 8 THEN CCN = 9
IF CCN > 15 THEN CCN = 1
DO X = 1 TO 7
CALL ASAY R+X-1,C,CCN,CL.X ;
END
CALL ASAY 24,60,0,""
RETURN
BUILDNUMBER:
ARG T
SELECT
WHEN DCC == 1 THEN DCT = "X"
WHEN DCC == 2 THEN DCT = T
OTHERWISE DCT = DC.DCC
END
CPT = TRANSLATE(CP.T,DCT,"X")
PARSE VALUE CPT WITH CL.1 9 CL.2 17 CL.3 25 CL.4 33 CL.5 41 CL.6 49 CL.7
RETURN
ASAY: PROCEDURE ;
PARSE ARG ROW,COL,ATTR,TSTR
AF = "30 34 32 36 31 35 33 37 1;30 1;34 1;32 1;36 1;31 1;35 1;33 1;37"
AB = "40m 44m 42m 46m 41m 45m 43m 47m 5;40m 5;44m 5;42m 5;46m 5;41m 5;45m 5;43m 5;47m"
ESC = "1b"x||"[" ;
CF = (ATTR // 16) ;
CB = (((ATTR - CF) / 16) // 128) ;
FC = WORD(AF,(CF+1)); BC = WORD(AB,(CB+1)) ;
IF ROW == 0 THEN TSTR = ESC||"2J" ;
IF ROW <> 0 THEN TSTR = TSTR||ESC||"0m" ;
TC = ESC||FC||";"||BC ;
SP = ESC||ROW||";"||COL||"H" ;
T = CHAROUT('',SP||TC||TSTR) ;
RETURN