'=========================================================================== ' Subject: CLOCK-LIKE DIGITS Date: 12-29-96 (18:36) ' Author: Mark Warner Code: QB, QBasic, PDS ' Origin: devilboy@cyberhall.com Packet: GRAPHICS.ABC '=========================================================================== DECLARE SUB Digits (x%, y%, Digit%, HiCol%, LowCol%) DEFINT A-Z SCREEN 13 h% = 0: i% = 0: j% = 0: k% = 0: l% = 0: m% = 0 c1% = 12 c2% = 230 DO WHILE r$ = "" h% = h% + 1 IF h% > 9 THEN h% = 0: i% = i% + 1 IF i% > 9 THEN i% = 0: j% = j% + 1 IF j% > 9 THEN j% = 0: k% = k% + 1 IF k% > 9 THEN k% = 0: l% = l% + 1 IF l% > 9 THEN l% = 0: m% = m% + 1 IF m% > 9 THEN SLEEP Digits 228, 0, m%, c1%, c2% Digits 240, 0, l%, c1%, c2% Digits 252, 0, k%, c1%, c2% Digits 264, 0, j%, c1%, c2% Digits 276, 0, i%, c1%, c2% Digits 288, 0, h%, c1%, c2% total& = m% * 100000 + l% * 10000 + k% * 1000 + j% * 100 + i% * 10 + h r$ = INKEY$ LOOP DEFSNG A-Z SUB Digits (x%, y%, Digit%, HiCol%, LowCol%) 'x% is the x coord for the upper left-hand corner of the digit 'y% is the y coord for the upper left-hand corner of the digit 'digit% is the number to be written to the screen 'HiCol% is the color of the "high" segments 'LowCol% is the color of the "low" segments ' 'Layout of seven-segment display: ' a ' ___ ' | | b ' f | g | ' --- ' | | c ' e | d | ' --- ' ' IF ABS(Digit%) = 0 THEN A% = 1: B% = 1: C% = 1: D% = 1: E% = 1: F% = 1: G% = 0 IF ABS(Digit%) = 1 THEN A% = 0: B% = 1: C% = 1: D% = 0: E% = 0: F% = 0: G% = 0 IF ABS(Digit%) = 2 THEN A% = 1: B% = 1: C% = 0: D% = 1: E% = 1: F% = 0: G% = 1 IF ABS(Digit%) = 3 THEN A% = 1: B% = 1: C% = 1: D% = 1: E% = 0: F% = 0: G% = 1 IF ABS(Digit%) = 4 THEN A% = 0: B% = 1: C% = 1: D% = 0: E% = 0: F% = 1: G% = 1 IF ABS(Digit%) = 5 THEN A% = 1: B% = 0: C% = 1: D% = 1: E% = 0: F% = 1: G% = 1 IF ABS(Digit%) = 6 THEN A% = 1: B% = 0: C% = 1: D% = 1: E% = 1: F% = 1: G% = 1 IF ABS(Digit%) = 7 THEN A% = 1: B% = 1: C% = 1: D% = 0: E% = 0: F% = 1: G% = 0 IF ABS(Digit%) = 8 THEN A% = 1: B% = 1: C% = 1: D% = 1: E% = 1: F% = 1: G% = 1 IF ABS(Digit%) = 9 THEN A% = 1: B% = 1: C% = 1: D% = 1: E% = 0: F% = 1: G% = 1 IF ABS(Digit%) > 9 OR Digit% < -9 THEN EXIT SUB IF A% = 1 THEN LINE (x% + 1, y% + 1)-(x% + 9, y% + 1), HiCol% ELSE LINE (x% + 1, y + 1)-(x% + 9, y% + 1), LowCol% IF B% = 1 THEN LINE (x% + 10, y% + 2)-(x% + 10, y% + 9), HiCol% ELSE LINE (x% + 10, y% + 2)-(x% + 10, y% + 9), LowCol% IF C% = 1 THEN LINE (x% + 10, y% + 11)-(x% + 10, y% + 19), HiCol% ELSE LINE (x% + 10, y% + 11)-(x% + 10, y% + 19), LowCol% IF D% = 1 THEN LINE (x% + 1, y% + 20)-(x% + 9, y% + 20), HiCol% ELSE LINE (x% + 1, y% + 20)-(x% + 9, y% + 20), LowCol% IF E% = 1 THEN LINE (x%, y% + 11)-(x%, y% + 19), HiCol% ELSE LINE (x%, y% + 11)-(x%, y% + 19), LowCol% IF F% = 1 THEN LINE (x%, y% + 2)-(x%, y% + 9), HiCol% ELSE LINE (x%, y% + 2)-(x%, y% + 9), LowCol% IF G% = 1 THEN LINE (x% + 1, y% + 10)-(x% + 9, y% + 10), HiCol% ELSE LINE (x% + 1, y% + 10)-(x% + 9, y% + 10), LowCol% END SUB