模拟显示电子数码
下面是从9到0倒记数程序:
其中第10句为设置初值,20--50句为循环,30句为调用子程序。40句控制显示停留的时间。
本程序在PC--286机、GWBASIC上通过。
10 X = 80: Y = 10: K = 20: C = 100: G = 40: SCREEN 1
20 FOR S = 1 TO 9: CLSGOSUB 500
30 FOR I = 1 TO 1000: NEXT I, SEND
500 IF S = 2 THEN 540
520 LINE (X + K + C, Y + 2 * K + G)-(X + 2 * K + C, Y + 2 * K + 2 * G), 3, BF
530 IF S = 5 OR S = 6 THEN 570
540 LINE (X + K + C, Y + K)-(X + 2 * K + C, Y + K + G), 3, BF
550 IF S = 1 THEN RETURN
560 IF S = 4 THEN 600
570 LINE (X + K, Y)-(X + K + C, Y + K), 3, BF
580 IF S = 7 THEN RETURN
590 IF S = 0 THEN 620
600 LINE (X + K, Y + K + G)-(X + K + C, Y + 2 * K + G), 3, BF
610 IF S = 4 THEN 650
620 LINE (X + K, Y + 2 * K + 2 * G)-(X + K + C, Y + 3 * K + 2 * G), 3, BF630 IF S = 3 THEN RETURN
640 IF S = 2 THEN 670
650 LINE (X, Y + K)-(X + K, Y + K + G), 3, BF
660 IF S = 4 OR S = 5 OR S = 9 THEN RETURN
670 LINE (X, Y + 2 * K + G)-(X + K, Y + 2 * K + 2 * G), 3, BF
680 RETURN(湖北 孔繁华)