'=========================================================================== ' Subject: RESITOR COLORS Date: 04-15-97 (21:55) ' Author: Davey W. Taylor Code: QB, QBasic, PDS ' Origin: audio.squad@mailbox.swipnet.se Packet: MISC.ABC '=========================================================================== 'ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ--ÄÄÄ--Ä -ù ù '³ RESISTOR COLORS '³ Davey W Taylor '³ '³ If you have any comments / suggestions / questions, my email is: '³ audio.squad@mailbox.swipnet.se '³ '³ do whatever you wish with this code, just as '³ long as you mention my name in your program 'ÀÄÄÄÄÄ--ÄÄù- ù ù '- program starts here -' CLS COLOR 7 PRINT "resistor colors use k for kilo / m for mega / o for ohm" PRINT "press to quit format ex: 1.2 ko Davey W Taylor" PRINT DO new: LINE INPUT "enter value: ", v$ 'get a resistor value IF LTRIM$(RTRIM$(v$)) = "" THEN END IF INSTR(v$, " ") = 0 THEN '- d$ = v$ '| separate the t$ = "o" '| actual value from ELSE '| the "suffix" d$ = LEFT$(v$, INSTR(v$, " ") - 1) '| t$ = MID$(v$, INSTR(v$, " ") + 1) '| END IF '- ok% = 1 FOR n% = 1 TO LEN(d$) IF INSTR("0123456789.", MID$(d$, n%, 1)) = 0 THEN '- COLOR 12 '| check for errors LOCATE , 13 + n% '| in the digits and PRINT "^"; '| print them to the COLOR 7 '| screen ok% = 0 '| END IF '| NEXT n% '- FOR n% = 1 TO LEN(t$) '- IF INSTR("kmo", MID$(t$, n%, 1)) = 0 THEN '| COLOR 12 '| check for errors LOCATE , 14 + LEN(d$) + n% '| in the "suffix" PRINT "^"; '| COLOR 7 '| ok% = 0 '| END IF '| NEXT n% '- IF ok% = 0 THEN PRINT : GOTO new '- '| the below line is to check for errors in the "suffix" '- IF t$ = "km" OR t$ = "mk" OR t$ = "ok" OR t$ = "om" OR t$ = "mm" OR t$ = "kk" OR t$ = "oo" THEN PRINT "format error!": GOTO new SELECT CASE LEFT$(t$, 1) '- CASE "k": v$ = LTRIM$(STR$(VAL(d$) * 1000)) '| check "suffix" CASE "m": v$ = LTRIM$(STR$(VAL(d$) * 1000000)) '| and multiply CASE ELSE: v$ = d$ '| END SELECT '- PRINT "ohm: "; v$ IF LEFT$(v$, 2) = "00" THEN PRINT "invalid entry!": GOTO new IF VAL(v$) <> INT(VAL(v$)) THEN PRINT "invalid entry!": GOTO new RESTORE colors '- FOR n% = 0 TO VAL(LEFT$(v$, 1)) '| get the three READ x1$ '| colors from the NEXT n% '| data block and RESTORE colors '| print them to FOR n% = 0 TO VAL(MID$(v$, 2, 1)) '| the screen READ x2$ '| NEXT n% '| RESTORE colors '| FOR n% = 2 TO LEN(v$) '| READ x3$ '| NEXT n% '| PRINT x1$; " "; x2$; " "; x3$ '- LOOP '- data block -' colors: DATA black,brown,red,orange,yellow,green,blue,violet,gray,white