'=========================================================================== ' Subject: TOLERANCE CALCULATOR Date: 02-17-94 (20:30) ' Author: Aaron Scott Zabudsky Code: QB, QBasic, PDS ' Origin: zabudsk@ecf.toronto.edu Packet: ALGOR.ABC '=========================================================================== DECLARE SUB CLR (x!) TYPE PrecNumber Value AS SINGLE Tol AS SINGLE END TYPE CLS LOCATE 2, 1 PRINT "[F]ind average of a set of numbers" PRINT "[C]hange a number" PRINT "[A]dd numbers together" PRINT "[M]ultiply numbers together" PRINT "[D]ivide numbers" PRINT "[R]aise number to a power" PRINT "[T]ransfer buffer to number" PRINT PRINT "Current Values Entered" DIM Buff AS PrecNumber DIM Nums(10) AS PrecNumber num = 0 Buff.Value = 0 Buff.Tol = 0 FOR counter = 1 TO 10 PRINT USING "## "; counter; PRINT Nums(counter).Value; "๑"; Nums(counter).Tol NEXT counter PRINT "ออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออ"; PRINT PRINT "Buffer: "; Buff.Value; "๑"; Buff.Tol a$ = "" WHILE a$ <> "Q" AND a$ <> CHR$(27) a$ = "" WHILE a$ = "" a$ = UCASE$(INKEY$) WEND IF a$ = "C" THEN LOCATE 23, 1 INPUT "Change number: ", t CLR 23 LOCATE 23, 1 INPUT "Value: ", Nums(t).Value CLR 23 LOCATE 23, 1 INPUT "Tolerance: ", Nums(t).Tol CLR 23 CLR 10 + t LOCATE 10 + t, 1 PRINT USING "## "; t; PRINT Nums(t).Value; "๑"; Nums(t).Tol END IF IF a$ = "A" THEN LOCATE 23, 1 INPUT "First Number (0 for buffer): ", t CLR 23 LOCATE 23, 1 INPUT "Second Number (0 for buffer): ", u CLR 23 IF (t <> 0) AND (u <> 0) THEN Buff.Value = Nums(t).Value + Nums(u).Value Buff.Tol = SQR(Nums(t).Tol ^ 2 + Nums(u).Tol ^ 2) ELSE IF t = 0 AND u <> 0 THEN Buff.Value = Buff.Value + Nums(u).Value Buff.Tol = SQR(Buff.Tol ^ 2 + Nums(u).Tol ^ 2) END IF IF t <> 0 AND u = 0 THEN Buff.Value = Buff.Value + Nums(t).Value Buff.Tol = SQR(Buff.Tol ^ 2 + Nums(t).Tol ^ 2) END IF IF t = 0 AND u = 0 THEN Buff.Value = Buff.Value * 2 Buff.Tol = SQR(2 * (Buff.Tol ^ 2)) END IF END IF CLR 22 LOCATE 22, 1 PRINT "Buffer: "; Buff.Value; "๑"; Buff.Tol END IF IF a$ = "F" THEN TotVal = 0 TotTol = 0 t = 1 Number = 0 WHILE t <> 0 LOCATE 23, 1 INPUT "Enter line to average: ", t TotVal = TotVal + Nums(t).Value TotTol = TotTol + Nums(t).Tol ^ 2 Number = Number + 1 CLR 23 WEND Number = Number - 1 IF Number > 0 THEN Buff.Value = TotVal / Number Buff.Tol = SQR(TotTol) / Number CLR 22 LOCATE 22, 1 PRINT "Buffer: "; Buff.Value; "๑"; Buff.Tol END IF END IF IF a$ = "T" THEN LOCATE 23, 1 INPUT "Enter destination line for buffer: ", t Nums(t).Value = Buff.Value Nums(t).Tol = Buff.Tol CLR 23 CLR 10 + t LOCATE 10 + t, 1 PRINT USING "## "; t; PRINT Nums(t).Value; "๑"; Nums(t).Tol END IF IF a$ = "M" OR a$ = "D" THEN LOCATE 23, 1 IF a$ = "D" THEN PRINT "Numerator or "; INPUT "First Number: ", t CLR 23 LOCATE 23, 1 IF a$ = "D" THEN PRINT "Denominator or "; INPUT "Second Number: ", u CLR 23 IF a$ = "M" THEN Buff.Value = Nums(t).Value * Nums(u).Value IF a$ = "D" THEN Buff.Value = Nums(t).Value / Nums(u).Value IF Nums(t).Tol <> 0 AND Nums(u).Tol <> 0 THEN Buff.Tol = Buff.Value * SQR((Nums(t).Tol / Nums(t).Value) ^ 2 + (Nums(u).Tol / Nums(u).Value) ^ 2) IF Nums(t).Tol = 0 AND Nums(u).Tol <> 0 THEN Buff.Tol = Nums(t).Value * Nums(u).Tol IF Nums(u).Tol = 0 THEN Buff.Tol = Nums(u).Value * Nums(t).Tol CLR 22 LOCATE 22, 1 PRINT "Buffer: "; Buff.Value; "๑"; Buff.Tol END IF IF a$ = "R" THEN LOCATE 23, 1 INPUT "Line Number to use as a Base: ", t CLR 23 LOCATE 23, 1 INPUT "Exponent: ", ex CLR 23 Buff.Value = Nums(t).Value ^ ex Buff.Tol = Buff.Value * ABS(ex) * (Nums(t).Tol / Nums(t).Value) CLR 22 LOCATE 22, 1 PRINT "Buffer: "; Buff.Value; "๑"; Buff.Tol END IF WEND SUB CLR (x) b = CSRLIN a = POS(0) LOCATE x, 1 PRINT SPACE$(80); LOCATE b, a END SUB