From a2ca3f43b5e4d1a112954c7e3aa2dfca4124e0f7 Mon Sep 17 00:00:00 2001 From: Svjatoslav Agejenko Date: Fri, 18 Oct 2024 01:02:50 +0300 Subject: [PATCH] Using AI to improve code readability --- Automation/School clock/kell3/kell3.bas | 436 ++++++++++++------------ 1 file changed, 216 insertions(+), 220 deletions(-) diff --git a/Automation/School clock/kell3/kell3.bas b/Automation/School clock/kell3/kell3.bas index 6239978..29557f5 100755 --- a/Automation/School clock/kell3/kell3.bas +++ b/Automation/School clock/kell3/kell3.bas @@ -1,5 +1,5 @@ -DECLARE FUNCTION getnam$ (a%) -DECLARE FUNCTION getsym$ (a$, b%) +DECLARE FUNCTION getName$ (a%) +DECLARE FUNCTION getSym$ (a$, b%) DECLARE SUB editor () DECLARE SUB leiaconf () DECLARE SUB clrerr () @@ -18,9 +18,9 @@ DECLARE SUB displukk () DECLARE SUB kola (a%) DECLARE SUB rese () DECLARE SUB start () -DECLARE SUB getnad (g%, n%, d%, k%) +DECLARE SUB getNad (g%, n%, d%, k%) DECLARE SUB initp (b$) -DECLARE SUB getmd (a$, m%, d%) +DECLARE SUB getMd (a$, m%, d%) DECLARE SUB son (a$) DECLARE SUB inita () DECLARE SUB chm () @@ -77,34 +77,34 @@ n1 = VAL(RIGHT$(a$, 4)) n2 = VAL(LEFT$(a$, 2)) a$ = LEFT$(a$, 5) n3 = VAL(RIGHT$(a$, 2)) -getnad n1, n2, n3, ndlp +getNad n1, n2, n3, ndlp FOR a = 1 TO apl -son ap$(a) -SELECT CASE sona$(1) -CASE "v" -getmd sona$(2), m1, d1 -getmd sona$(3), m2, d2 -getmd DATE$, m3, d3 -IF m3 < m1 THEN GOTO 9 -IF m3 > m2 THEN GOTO 9 -IF m3 = m1 THEN IF d3 < d1 THEN GOTO 9 -IF m3 = m2 THEN IF d3 > d2 THEN GOTO 9 -b$ = sona$(4) -CASE "n" -getmd sona$(2), m1, d1 -getmd sona$(3), m2, d2 -getmd DATE$, m3, d3 -IF m3 < m1 THEN GOTO 9 -IF m3 > m2 THEN GOTO 9 -IF m3 = m1 THEN IF d3 < d1 THEN GOTO 9 -IF m3 = m2 THEN IF d3 > d2 THEN GOTO 9 -IF ndlp <> VAL(sona$(4)) THEN GOTO 9 -b$ = sona$(5) -CASE "e" -getmd sona$(2), m1, d1 -getmd DATE$, m2, d2 -IF (m1 = m2) AND (d1 = d2) THEN b$ = sona$(3) -END SELECT + son ap$(a) + SELECT CASE sona$(1) + CASE "v" + getMd sona$(2), m1, d1 + getMd sona$(3), m2, d2 + getMd DATE$, m3, d3 + IF m3 < m1 THEN GOTO 9 + IF m3 > m2 THEN GOTO 9 + IF m3 = m1 THEN IF d3 < d1 THEN GOTO 9 + IF m3 = m2 THEN IF d3 > d2 THEN GOTO 9 + b$ = sona$(4) + CASE "n" + getMd sona$(2), m1, d1 + getMd sona$(3), m2, d2 + getMd DATE$, m3, d3 + IF m3 < m1 THEN GOTO 9 + IF m3 > m2 THEN GOTO 9 + IF m3 = m1 THEN IF d3 < d1 THEN GOTO 9 + IF m3 = m2 THEN IF d3 > d2 THEN GOTO 9 + IF ndlp <> VAL(sona$(4)) THEN GOTO 9 + b$ = sona$(5) + CASE "e" + getMd sona$(2), m1, d1 + getMd DATE$, m2, d2 + IF (m1 = m2) AND (d1 = d2) THEN b$ = sona$(3) + END SELECT 9 NEXT a @@ -121,18 +121,18 @@ IF a$ <> dato$ THEN chd dato$ = a$ b = 0 FOR a = 1 TO ppl -son pp$(a) -SELECT CASE sona$(1) -CASE "#" -getmd sona$(2), h1, m1 -getmd TIME$, h2, m2 -' PRINT h1, m1, h2, m2 -IF (h2 = h1) AND (m2 = m1) THEN -IF sona$(3) = "sis" THEN b = 1 -IF sona$(3) = "val" THEN b = 2 -END IF -END SELECT -NEXT a + son pp$(a) + SELECT CASE sona$(1) + CASE "#" + getMd sona$(2), h1, m1 + getMd TIME$, h2, m2 + ' PRINT h1, m1, h2, m2 + IF (h2 = h1) AND (m2 = m1) THEN + IF sona$(3) = "sis" THEN b = 1 + IF sona$(3) = "val" THEN b = 2 + END IF + END SELECT + NEXT a IF (tunnidara = 0) AND (b > 0) THEN kell b ssave = ssave + 1 @@ -160,14 +160,13 @@ dispp LOCATE 12, 15 PRINT "Kuu-P�ev-Aasta (USA standard)" - LOCATE 17 FOR a = 1 TO ppl -IF pp$(a) <> SPACE$(LEN(pp$(a))) THEN - PRINT pp$(a); - PRINT SPACE$(15 - LEN(pp$(a))); -END IF + IF pp$(a) <> SPACE$(LEN(pp$(a))) THEN + PRINT pp$(a); + PRINT SPACE$(15 - LEN(pp$(a))); + END IF NEXT a displukk @@ -177,11 +176,11 @@ END SUB SUB displukk LOCATE 1, 40 IF kblukk = 1 THEN - COLOR 0, 7 - PRINT "Klaviatuur lukus! Vajuta CTRL+L" - COLOR 15, 0 + COLOR 0, 7 + PRINT "Klaviatuur lukus! Vajuta CTRL+L" + COLOR 15, 0 ELSE - PRINT " " + PRINT " " END IF END SUB @@ -198,9 +197,9 @@ SUB dispt LOCATE 16, 20 COLOR 12 + 15, 0 IF tunnidara = 1 THEN - PRINT "T2na on k6ik tunnid 2ra j2etud" + PRINT "T2na on k6ik tunnid 2ra j2etud" ELSE - PRINT " " + PRINT " " END IF COLOR 15, 0 END SUB @@ -213,39 +212,38 @@ COLOR 0, 15 LOCATE 1, 1 PRINT SPACE$(80); LOCATE 1, 1 -PRINT "Konfiguratsiooni redaktor. Valige v2lja p2eva v6i aasta plaani." +PRINT "Konfiguratsiooni redaktor. Valige v�lja p�eva v6i aasta plaani." LOCATE 2, 1 -PRINT SPACE$(80); +PRINT SPACE$(80) LOCATE 2, 1 PRINT " nr nimi laiend suurus loomisdaatum" LOCATE 22, 1 -PRINT SPACE$(80); +PRINT SPACE$(80) LOCATE 22, 1 -PRINT "K - valitud faili kustutamine U - uus fail ESC - redaktorist v2lja" +PRINT "K - valitud faili kustutamine U - uus fail ESC - redaktorist v�lja" p = 0 v = 1 17 FOR a = 3 TO 21 - IF a - 2 + p = v THEN - COLOR 0, 7 - LOCATE a, 1 - PRINT cnflist$(a - 2 + p) + SPACE$(55 - LEN(cnflist$(a - 2 + p))) - LOCATE a, 56 - COLOR 31, 0 - PRINT "<=="; - IF cnflist$(a - 2 + p) <> SPACE$(LEN(cnflist$(a - 2 + p))) THEN - COLOR 15, 0 - PRINT " valitud: " + getnam$(v) + IF a - 2 + p = v THEN + COLOR 0, 7 + LOCATE a, 1 + PRINT cnflist$(a - 2 + p) + SPACE$(55 - LEN(cnflist$(a - 2 + p))) + LOCATE a, 56 + COLOR 31, 0 + PRINT "<==" + IF cnflist$(a - 2 + p) <> SPACE$(LEN(cnflist$(a - 2 + p))) THEN + COLOR 15, 0 + PRINT " valitud: " + getName$(v) + END IF + COLOR 15, 0 + ELSE + COLOR 15, 0 + LOCATE a, 1 + PRINT cnflist$(a - 2 + p) + SPACE$(80 - LEN(cnflist$(a - 2 + p))) END IF - COLOR 15, 0 - ELSE - COLOR 15, 0 - LOCATE a, 1 - PRINT cnflist$(a - 2 + p) + SPACE$(80 - LEN(cnflist$(a - 2 + p))) - END IF NEXT a - a$ = INKEY$ LOCATE 1, 1 @@ -257,31 +255,33 @@ IF a$ = CHR$(0) + "H" THEN v = v - 1 IF a$ = CHR$(0) + CHR$(73) THEN v = v - 17 IF a$ = CHR$(0) + CHR$(81) THEN v = v + 17 IF a$ = "K" OR a$ = "k" THEN - IF LEN(getnam$(v)) > 2 THEN - IF getnam$(v) = "AASTA.AP" THEN - SOUND 3000, .1 + IF LEN(getName$(v)) > 2 THEN + IF getName$(v) = "AASTA.AP" THEN + SOUND 3000, .1 + ELSE + KILL getName$(v) + GOTO 23 + END IF ELSE - KILL getnam$(v) - GOTO 23 + SOUND 3000, .1 END IF - ELSE - SOUND 3000, .1 - END IF END IF IF a$ = CHR$(13) THEN - IF getnam$(v) = "." THEN - SOUND 3000, .1 - ELSE - SHELL "EDIT " + getnam$(v) - GOTO 23 - END IF + IF getName$(v) = "." THEN + SOUND 3000, .1 + ELSE + SHELL "EDIT " + getName$(v) + GOTO 23 + END IF END IF IF v < 1 THEN v = 1: SOUND 3000, .2 IF v > 200 THEN v = 200: : SOUND 3000, .2 -21 IF v - p > 19 THEN p = p + 1: GOTO 21 -22 IF v - p < 1 THEN p = p - 1: GOTO 22 +21 +IF v - p > 19 THEN p = p + 1: GOTO 21 +22 +IF v - p < 1 THEN p = p - 1: GOTO 22 GOTO 17 18 @@ -289,14 +289,14 @@ COLOR 15, 0 disp END SUB -SUB getmd (a$, m, d) +SUB getMd (a$, m, d) b$ = LEFT$(a$, 5) m = VAL(LEFT$(b$, 2)) d = VAL(RIGHT$(b$, 2)) END SUB -SUB getnad (g, n, d, k) +SUB getNad (g, n, d, k) 'LOCATE 11, 1 'PRINT g, n, d p = g @@ -311,57 +311,54 @@ k = w - 7 * INT(w / 7) IF k = 0 THEN k = 7 END SUB -FUNCTION getnam$ (a) +FUNCTION getName$ (a) c$ = "" FOR b = 8 TO 40 - d$ = getsym(cnflist$(a), b) - IF d$ = " " THEN GOTO 19 - c$ = c$ + d$ + d$ = getSym(cnflist$(a), b) + IF d$ = " " THEN GOTO 19 + c$ = c$ + d$ NEXT b 19 -getnam$ = c$ + "." + getsym(cnflist$(a), 17) + getsym(cnflist$(a), 18) +getName$ = c$ + "." + getSym(cnflist$(a), 17) + getSym(cnflist$(a), 18) END FUNCTION -FUNCTION getsym$ (a$, b) -getsym$ = RIGHT$(LEFT$(a$, b), 1) +FUNCTION getSym$ (a$, b) +getSym$ = RIGHT$(LEFT$(a$, b), 1) END FUNCTION SUB heli (a) 'GOTO 10 SELECT CASE a -CASE 1 -FOR c = 1 TO 5 -SOUND 3000, 1 -SOUND 0, 1 -NEXT c - -CASE 2 -FOR c = 1 TO 5 -SOUND 2500, 1 -SOUND 0, 2 -NEXT c -SOUND 2500, 10 - -CASE 3 -FOR a = 1 TO 10 -SOUND 500, .5 -SOUND 1500, .5 -SOUND 2000, .5 -SOUND 1520, .5 -NEXT a - - -CASE 4 -FOR a = 800 TO 1000 STEP 10 -SOUND a, .1 -SOUND a * 3, .1 -SOUND 0, 1 -NEXT a -10 - + CASE 1 + FOR c = 1 TO 5 + SOUND 3000, 1 + SOUND 0, 1 + NEXT c + + CASE 2 + FOR c = 1 TO 5 + SOUND 2500, 1 + SOUND 0, 2 + NEXT c + SOUND 2500, 10 + + CASE 3 + FOR a = 1 TO 10 + SOUND 500, .5 + SOUND 1500, .5 + SOUND 2000, .5 + SOUND 1520, .5 + NEXT a + + CASE 4 + FOR a = 800 TO 1000 STEP 10 + SOUND a, .1 + SOUND a * 3, .1 + SOUND 0, 1 + NEXT a + 10 END SELECT - END SUB SUB inita @@ -381,7 +378,7 @@ END SUB SUB initp (b$) ppl = 0 -errmsg$ = "Ei leia aastaplaanis mainitud '" + b$ + ".pp' p2evaplaani!" +errmsg$ = "Ei leia aastaplaanis mainitud '" + b$ + ".pp' p�evaplaani!" OPEN b$ + ".pp" FOR INPUT AS #1 clrerr 6 @@ -401,26 +398,28 @@ IF b$ <> lk$ THEN lk$ = b$ ELSE GOTO 2 heli 3 SELECT CASE a -CASE 1 -kola 4 -FOR b = 1 TO 15 -SOUND 0, 1 -NEXT b -kola 1 -CASE 2 -kola 5 + CASE 1 + kola 4 + FOR b = 1 TO 15 + SOUND 0, 1 + NEXT b + kola 1 + + CASE 2 + kola 5 END SELECT 2 + END SUB SUB kola (a) COLOR 15, 7 s$ = "" FOR b = 1 TO 80 - s$ = s$ + CHR$(219) + s$ = s$ + CHR$(219) NEXT b FOR b = 1 TO 30 -PRINT s$; + PRINT s$; NEXT b timero = TIMER @@ -434,7 +433,7 @@ END SUB SUB leiaconf FOR a = 1 TO 200 - cnflist$(a) = "" + cnflist$(a) = "" NEXT a c = 1 @@ -447,7 +446,7 @@ IF LEN(a$) < 30 THEN GOTO 15 IF LEFT$(a$, 1) = " " THEN GOTO 15 IF LEFT$(a$, 1) = "." THEN GOTO 15 b$ = RIGHT$(LEFT$(a$, 12), 3) -IF b$ = "PP " OR b$ = "AP " THEN ELSE GOTO 15 +IF b$ = "PP " OR b$ = "AP " THEN ELSE GOTO 15 d$ = " " + STR$(c) a$ = RIGHT$(d$, 4) + " " + a$ IF LEN(a$) > 50 THEN a$ = LEFT$(a$, 50) @@ -468,17 +467,17 @@ timo$ = b$ a$ = INKEY$ IF a$ <> "" THEN -IF ssave > ssavel THEN disp -ssave = 0 + IF ssave > ssavel THEN disp + ssave = 0 END IF IF a$ = CHR$(12) THEN - IF kblukk = 1 THEN kblukk = 0 ELSE kblukk = 1 - displukk + IF kblukk = 1 THEN kblukk = 0 ELSE kblukk = 1 + displukk END IF IF kblukk = 1 THEN - IF a$ <> "" THEN SOUND 3000, 1 - a$ = "" + IF a$ <> "" THEN SOUND 3000, 1 + a$ = "" END IF IF a$ = "k" OR a$ = "K" THEN editor @@ -486,51 +485,51 @@ IF a$ = "s" OR a$ = "S" THEN kell 1 IF a$ = "v" OR a$ = "V" THEN kell 2 IF a$ = "a" THEN -CLS -PRINT " vana aeg: " + TIME$ -INPUT "sisesta uus aeg (TT:MM:SS): ", b$ -IF LEN(b$) <> 8 THEN GOTO 12 -TIME$ = b$ -timo$ = "" -12 -disp + CLS + PRINT " vana aeg: " + TIME$ + INPUT "sisesta uus aeg (TT:MM:SS): ", b$ + IF LEN(b$) <> 8 THEN GOTO 12 + TIME$ = b$ + timo$ = "" + 12 + disp END IF IF a$ = "d" OR a$ = "D" THEN -CLS -PRINT " vana daatum: " + DATE$ -INPUT "sisesta uus daatum (KK-PP-AAAA): ", b$ -IF LEN(b$) <> 10 THEN GOTO 13 -DATE$ = b$ -timo$ = "" -13 -disp + CLS + PRINT " vana daatum: " + DATE$ + INPUT "sisesta uus daatum (KK-PP-AAAA): ", b$ + IF LEN(b$) <> 10 THEN GOTO 13 + DATE$ = b$ + timo$ = "" + 13 + disp END IF IF a$ = "7" OR a$ = "8" THEN - b = VAL(RIGHT$(LEFT$(TIME$, 5), 2)) - IF a$ = "7" THEN b = b - 1 - IF a$ = "8" THEN b = b + 1 - IF b < 0 THEN b = 0 - IF b > 59 THEN b = 59 - d$ = STR$(b) - IF LEFT$(d$, 1) = " " THEN d$ = RIGHT$(d$, LEN(d$) - 1) - IF LEN(d$) < 2 THEN d$ = "0" + d$ - e$ = LEFT$(TIME$, 3) + d$ + RIGHT$(TIME$, 3) - TIME$ = e$ + b = VAL(RIGHT$(LEFT$(TIME$, 5), 2)) + IF a$ = "7" THEN b = b - 1 + IF a$ = "8" THEN b = b + 1 + IF b < 0 THEN b = 0 + IF b > 59 THEN b = 59 + d$ = STR$(b) + IF LEFT$(d$, 1) = " " THEN d$ = RIGHT$(d$, LEN(d$) - 1) + IF LEN(d$) < 2 THEN d$ = "0" + d$ + e$ = LEFT$(TIME$, 3) + d$ + RIGHT$(TIME$, 3) + TIME$ = e$ END IF IF a$ = "4" OR a$ = "5" THEN - b = VAL(LEFT$(TIME$, 2)) - IF a$ = "4" THEN b = b - 1 - IF a$ = "5" THEN b = b + 1 - IF b < 0 THEN b = 0 - IF b > 23 THEN b = 23 - d$ = STR$(b) - IF LEFT$(d$, 1) = " " THEN d$ = RIGHT$(d$, LEN(d$) - 1) - IF LEN(d$) < 2 THEN d$ = "0" + d$ - e$ = d$ + RIGHT$(TIME$, 6) - TIME$ = e$ + b = VAL(LEFT$(TIME$, 2)) + IF a$ = "4" THEN b = b - 1 + IF a$ = "5" THEN b = b + 1 + IF b < 0 THEN b = 0 + IF b > 23 THEN b = 23 + d$ = STR$(b) + IF LEFT$(d$, 1) = " " THEN d$ = RIGHT$(d$, LEN(d$) - 1) + IF LEN(d$) < 2 THEN d$ = "0" + d$ + e$ = d$ + RIGHT$(TIME$, 6) + TIME$ = e$ END IF IF a$ = "p" OR a$ = "P" THEN SHELL "EDIT juhend.txt": disp @@ -539,37 +538,36 @@ IF a$ = "r" OR a$ = "R" THEN rese IF a$ = "q" OR a$ = "Q" THEN SYSTEM IF a$ = "j" OR a$ = "J" THEN -IF tunnidara = 0 THEN tunnidara = 1 ELSE tunnidara = 0 -dispt + IF tunnidara = 0 THEN tunnidara = 1 ELSE tunnidara = 0 + dispt END IF IF ssave <= ssavel THEN - LOCATE 11, 1 - PRINT TIME$ - LOCATE 12, 1 - PRINT DATE$ + LOCATE 11, 1 + PRINT TIME$ + LOCATE 12, 1 + PRINT DATE$ ELSE - IF ABS(TIMER - timero) > 10 THEN - CLS - kblukk = 1 - FOR b = 1 TO 20 - LOCATE RND * 22 + 1, RND * 79 + 1 - IF RND * 100 < 50 THEN PRINT "*" ELSE PRINT "." - NEXT b - LOCATE RND * 22 + 1, RND * 50 + 1 - COLOR 0, 7 - PRINT "< " + LEFT$(TIME$, 2); - COLOR 16, 7 - PRINT ":"; - COLOR 0, 7 - PRINT RIGHT$(LEFT$(TIME$, 5), 2) + " >" - COLOR 15, 0 - timero = TIMER - END IF + IF ABS(TIMER - timero) > 10 THEN + CLS + kblukk = 1 + FOR b = 1 TO 20 + LOCATE RND * 22 + 1, RND * 79 + 1 + IF RND * 100 < 50 THEN PRINT "*" ELSE PRINT "." + NEXT b + LOCATE RND * 22 + 1, RND * 50 + 1 + COLOR 0, 7 + PRINT "< " + LEFT$(TIME$, 2); + COLOR 16, 7 + PRINT ":"; + COLOR 0, 7 + PRINT RIGHT$(LEFT$(TIME$, 5), 2) + " >" + COLOR 15, 0 + timero = TIMER + END IF END IF GOTO 1 - END SUB SUB rese @@ -582,22 +580,21 @@ END SUB SUB son (a$) FOR b = 1 TO 50 - sona$(b) = "" + sona$(b) = "" NEXT b mitus = 0 b = 1 FOR c = 1 TO LEN(a$) -d$ = RIGHT$(LEFT$(a$, c), 1) -IF d$ = " " OR d$ = CHR$(9) THEN -b = 1 -ELSE -IF b = 1 THEN b = 0: mitus = mitus + 1 -sona$(mitus) = sona$(mitus) + d$ -END IF + d$ = RIGHT$(LEFT$(a$, c), 1) + IF d$ = " " OR d$ = CHR$(9) THEN + b = 1 + ELSE + IF b = 1 THEN b = 0: mitus = mitus + 1 + sona$(mitus) = sona$(mitus) + d$ + END IF NEXT c - END SUB SUB start @@ -619,4 +616,3 @@ tunnidara = 0 OUT prt, 0 END SUB - -- 2.20.1