Thursday, January 8, 2015

Text clock.

Text clocks seem to be a big thing right now. Here is one written in qbasic.

qb64 result:


Freebasic result:


Source code:

[code]
'UNSEEN'S NOT A STANDARD CLOCK
DIM SEC AS STRING, MIN AS STRING, HR AS STRING
SCREEN 0: COLOR 3, 15: WIDTH 40, 25
CLS
DO
HR$ = LEFT$(TIME$, 2): MIN$ = MID$(TIME$, 4, 2): SEC$ = RIGHT$(TIME$, 2)
LOCATE 1, 1: PRINT HR$; ":"; MIN$; ":"; SEC$
'MINUTES
IF (VAL(MIN$) <  10 and val(min$) >= 5) OR (VAL(MIN$) >= 55 AND VAL(MIN$) < 60) THEN COLOR 12, 15
LOCATE 3, 2: PRINT "FIVE": COLOR 3, 15
IF VAL(MIN$) >= 10 AND VAL(MIN$) < 15 OR VAL(MIN$) >= 50 AND VAL(MIN$) < 55 THEN COLOR 12, 15
LOCATE 3, 8: PRINT "TEN": COLOR 3, 15
IF VAL(MIN$) >= 15 AND VAL(MIN$) < 20 OR VAL(MIN$) >= 45 AND VAL(MIN$) < 50 THEN COLOR 12, 15
LOCATE 3, 13: PRINT "FIFTEEN": COLOR 3, 15
IF VAL(MIN$) >= 20 AND VAL(MIN$) < 25 OR VAL(MIN$) >= 40 AND VAL(MIN$) < 45 THEN COLOR 12, 15
LOCATE 3, 21: PRINT "TWENTY": COLOR 3, 15
IF VAL(MIN$) >= 25 AND VAL(MIN$) < 30 OR VAL(MIN$) >= 35 AND VAL(MIN$) < 40 THEN COLOR 12, 15
LOCATE 3, 28: PRINT "TWENTY FIVE": COLOR 3, 15
LOCATE 7, 12: PRINT "MIN'S"
'EXTRA MINUTES
IF VAL(MIN$) > 30 THEN COLOR 12, 15
LOCATE 5, 3: PRINT "MINUS": COLOR 3, 15
IF VAL(MIN$) < 30 THEN COLOR 12, 15
LOCATE 5, 10: PRINT "PLUS": COLOR 3, 15
IF VAL(MID$(TIME$, 5, 1)) = 6 OR VAL(MID$(TIME$, 5, 1)) = 4 THEN COLOR 12, 15
LOCATE 7, 3: PRINT "1": COLOR 3, 15
IF VAL(MID$(TIME$, 5, 1)) = 7 OR VAL(MID$(TIME$, 5, 1)) = 3 THEN COLOR 12, 15
LOCATE 7, 5: PRINT "2": COLOR 3, 15
IF VAL(MID$(TIME$, 5, 1)) = 8 OR VAL(MID$(TIME$, 5, 1)) = 2 THEN COLOR 12, 15
LOCATE 7, 7: PRINT "3": COLOR 3, 15
IF VAL(MID$(TIME$, 5, 1)) = 9 OR VAL(MID$(TIME$, 5, 1)) = 1 THEN COLOR 12, 15
LOCATE 7, 9: PRINT "4": COLOR 3, 15
'TO PAST
IF VAL(MIN$) > 30 THEN COLOR 12, 15
LOCATE 9, 10: PRINT "TO THE NEXT HOUR": COLOR 3, 15
IF VAL(MIN$) <= 30 THEN COLOR 12, 15
LOCATE 9, 30: PRINT "PAST": : COLOR 3, 15
IF VAL(MIN$) = 30 THEN COLOR 12, 15
LOCATE 9, 36: PRINT "HALF ": COLOR 3, 15
'HOURS
IF VAL(HR$) = 1 OR VAL(HR$) = 13 THEN COLOR 12, 15
LOCATE 11, 2: PRINT "ONE": COLOR 3, 15
IF VAL(HR$) = 2 OR VAL(HR$) = 14 THEN COLOR 12, 15
LOCATE 11, 7: PRINT "TWO": COLOR 3, 15
IF VAL(HR$) = 3 OR VAL(HR$) = 15 THEN COLOR 12, 15
LOCATE 11, 12: PRINT "THREE": COLOR 3, 15
IF VAL(HR$) = 4 OR VAL(HR$) = 16 THEN COLOR 12, 15
LOCATE 11, 19: PRINT "FOUR": COLOR 3, 15
IF VAL(HR$) = 5 OR VAL(HR$) = 17 THEN COLOR 12, 15
LOCATE 11, 25: PRINT "FIVE": COLOR 3, 15
IF VAL(HR$) = 6 OR VAL(HR$) = 18 THEN COLOR 12, 15
LOCATE 11, 30: PRINT "SIX": COLOR 3, 15
IF VAL(HR$) = 7 OR VAL(HR$) = 19 THEN COLOR 12, 15
LOCATE 11, 35: PRINT "SEVEN": COLOR 3, 15
IF VAL(HR$) = 8 OR VAL(HR$) = 20 THEN COLOR 12, 15
LOCATE 12, 5: PRINT "EIGHT": COLOR 3, 15
IF VAL(HR$) = 9 OR VAL(HR$) = 21 THEN COLOR 12, 15
LOCATE 12, 12: PRINT "NINE": COLOR 3, 15
IF VAL(HR$) = 10 OR VAL(HR$) = 22 THEN COLOR 12, 15
LOCATE 12, 18: PRINT "TEN": COLOR 3, 15
IF VAL(HR$) = 11 OR VAL(HR$) = 23 THEN COLOR 12, 15
LOCATE 12, 23: PRINT "ELEVEN": COLOR 3, 15
IF VAL(HR$) = 0 OR VAL(HR$) = 12 THEN COLOR 12, 15
LOCATE 12, 31: PRINT "TWELVE": COLOR 3, 15
'AM-PM
IF VAL(HR$) >= 12 THEN COLOR 12, 15
LOCATE 16, 5: PRINT "PM": COLOR 3, 15
IF VAL(HR$) < 12 THEN COLOR 12, 15
LOCATE 16, 2: PRINT "AM": COLOR 3, 15
'SECONDS
COLOR 12, 15: LOCATE 19, 2: PRINT "AND"
COLOR 3, 15
IF VAL(SEC$) = 5 THEN COLOR 12, 15
LOCATE 21, 1: PRINT "5": COLOR 3, 15
IF VAL(SEC$) = 10 THEN COLOR 12, 15
LOCATE 21, 3: PRINT "10": COLOR 3, 15
IF VAL(SEC$) = 15 THEN COLOR 12, 15
LOCATE 21, 7: PRINT "15": COLOR 3, 15
IF VAL(SEC$) = 20 THEN COLOR 12, 15
LOCATE 21, 11: PRINT "20": COLOR 3, 15
IF VAL(SEC$) = 25 THEN COLOR 12, 15
LOCATE 21, 15: PRINT "25": COLOR 3, 15
IF VAL(SEC$) = 30 THEN COLOR 12, 15
LOCATE 21, 19: PRINT "30": COLOR 3, 15
IF VAL(SEC$) = 35 THEN COLOR 12, 15
LOCATE 21, 23: PRINT "35": COLOR 3, 15
IF VAL(SEC$) = 40 THEN COLOR 12, 15
LOCATE 21, 27: PRINT "40": COLOR 3, 15
IF VAL(SEC$) = 45 THEN COLOR 12, 15
LOCATE 21, 31: PRINT "45": COLOR 3, 15
IF VAL(SEC$) = 50 THEN COLOR 12, 15
LOCATE 21, 35: PRINT "50": COLOR 3, 15
IF VAL(SEC$) = 55 THEN COLOR 12, 15
LOCATE 21, 39: PRINT "55": COLOR 3, 15
COLOR 12, 15: LOCATE 23, 32: PRINT "SECONDS"
COLOR 3, 15
LOOP
[/code]

No comments:

Post a Comment