FILE+

Date: 198x
Type: Program
Platform(s): TS 2068
Tags: Utility

FILE+ is a menu-driven collection of ten educational math and science programs covering topics such as polynomial evaluation, greatest common divisor (via both trial-and-error and Euclidean algorithm methods), prime number generation, unit conversion, capacitor-resistor circuit simulation, molecular weight calculation, genetics simulation, and heat of reaction calculation. The program uses RESTORE with specific line numbers to re-read DATA statements for the GCD, Euclidean algorithm, capacitor-resistor, and molecular weight routines. The genetics module uses RND to simulate random allele selection from parent genotype arrays, printing individual offspring results and final brown-to-blue eye ratios. The heat of reaction section (lines 1810–1940) contains a bug at line 1900: it references variables C and M, which are never assigned, rather than the correct expressions using the previously collected input values T, L, G, and S.


Program Structure

FILE+ is a monolithic BASIC file containing ten self-contained educational routines accessed through a central menu at lines 30–160. Each routine occupies a contiguous block of line numbers and ends with a Y/N prompt that either restarts the routine or returns to the main menu via RUN. Line 1960 saves the program with auto-run enabled from line 10.

Menu OptionTopicStart Line
1Polynomial Evaluation170
2Greatest Common Divisor (Trial & Error)300
3Euclidean Algorithm GCD500
4Prime Numbers ≤ N730
5Standard to Metric Conversion910
6Capacitor-Resistor Circuit1110
7Molecular Weight of Compounds1260
8Genetics Simulation1570
9Heat of Reaction1810
10SINEX (not implemented)

Menu and Navigation

The main menu reads the user’s choice into a at line 60, then checks A (the same variable, case-insensitive in this BASIC dialect) against the range 1–10 at line 70. Lines 80–160 dispatch with a chain of IF A=n THEN GO TO statements. Returning from any sub-program is done with RUN, which restarts the program from line 10, effectively re-displaying the menu.

DATA and RESTORE Usage

Several routines embed their own DATA statements and use RESTORE with a specific line number to rewind to the correct data set before reading. This is necessary because all DATA exists in a single global pool.

  • Line 300: RESTORE 330 before reading GCD values from line 460.
  • Line 500: RESTORE 510 before reading Euclidean algorithm data from line 690.
  • Line 1110: RESTORE 1110 before reading capacitor-resistor circuit parameters from line 1220.
  • Line 1260: RESTORE 1260 before reading the 16-element atomic weight table from lines 1500–1530.

Note that routines 2 and 3 use hardcoded DATA rather than user input for their number sets; line 320 contains the remnant comment REM INPUT "INPUT NUMBER. ";k, indicating this was originally interactive.

Notable Techniques

Prime number generation (lines 800–870): Uses trial division up to √I + 0.01 (the small offset guards against floating-point rounding when I is a perfect square). Line 790 prints 2 unconditionally, then the loop starts at I=2, meaning 2 is tested again but the inner J loop from 2 to √2 evaluates Q=1, which is an integer, causing GO TO 870 — so 2 is not re-printed. However, composite numbers that happen to divide evenly are skipped correctly via GO TO 870 (skipping the PRINT I at line 860).

Molecular weight lookup (lines 1330–1470): Reads 16 element symbols and atomic weights into parallel arrays S$ and W, then performs a linear search for each user-supplied element symbol. The supported elements are O, H, C, N, F, B, P, S, K, CL, MG, NA, FE, CA, AG, and ZN.

Capacitor-resistor simulation (lines 1140–1210): Implements a first-order RC charging circuit using an Euler forward-difference method. The variable K is initialized to 10 and used as a counter to print one row every 10 iterations, displaying time rounded to two decimal places via INT(T*100+.5)/100. The loop at line 1210 is infinite — there is no termination condition, so the program runs until interrupted by the user.

Genetics simulation (lines 1630–1720): Each offspring’s alleles are selected by indexing into two 2-element string arrays M$ and F$ using INT(RND*2+1) to generate either 1 or 2. A dominant “BR” (brown) allele in either parent position produces a brown phenotype; only “BL”,”BL” combinations count as blue. Results are tallied and a ratio is printed.

Rounding idiom: The expression INT(X*10+.05)/10 at line 1770 rounds a ratio to one decimal place, a common BASIC technique in the absence of a native rounding function.

Bugs and Anomalies

  • Heat of Reaction (line 1900): PRINT "CALORIES PER MOLE = ";C/M references variables C and M, which are never assigned in this routine. The inputs collected are T (temperature change), L (grams or mL of water), G (grams of substance), and S (molar mass). The intended expression was likely (T*L)/(G/S), i.e., calories divided by moles.
  • GCD Trial-and-Error (lines 350–400): The inner loop at line 370 checks only whether A (the last value read) is divisible by D, not all K values. The loop variable I iterates but A is never updated within it, so the divisibility test is applied to only the final element read. This is a logic error that would produce incorrect GCDs for most input sets.
  • Menu input variable case: Line 60 uses lowercase a in the INPUT prompt string, but line 70 onward uses uppercase A. In this BASIC, these refer to the same variable, so this is a cosmetic inconsistency only.
  • Molecular weight typo (line 1030): PRINT N;" INCHES=";N*254;" CENTIMETERS" — converting inches to centimeters requires multiplying by 2.54, not 254. This is off by a factor of 100 (gives millimeters, not centimeters).
  • Spelling errors in listing: “POLYOMIAL” (line 40), “CIRCUT” (line 50), “GIVIN” (line 680), and “INTERGERS” (line 450) are present in the original source strings.
  • Option 10 (SINEX): The menu lists this option and the dispatch at line 160 would GO TO line 1810 (same as Heat of Reaction, since no line exists beyond that), but no implementation is provided.

Key BASIC Idioms

  • CLEAR at the start of each sub-program to free string space and reset variables.
  • Chained IF … THEN GO TO for all branching — no structured SELECT CASE equivalent.
  • INPUT "prompt";var combining prompt and input on one line.
  • PRINT ' (apostrophe after PRINT) used to emit a blank line before the next item.
  • The RUN statement used as a “return to menu” mechanism, relying on program re-execution from line 10.

Source Code

   10 REM PROGRAMS FROM MICROCOMPUTERS AND THE 3 R'S BY CHRISTINE  DOERR ©1979
   20 CLEAR 
   30 PRINT "MENU"
   40 PRINT '"1) POLYOMIAL EVALUATION"'"2) GREATEST COMMON DIVISOR"'"3) EUCLIDEAN ALGORITHM"'"4) PRIME NUMBERS"'"5) STANDARD TO METRIC"
   50 PRINT "6) CAPACITOR-RESISTOR CIRCUT"'"7) MOLECULAR WEIGHT OF COMPOUNDS8) GENETICS"'"9) HEAT OF REACTION"'"10) SINEX (not ready yet)"
   60 INPUT "INPUT THE PROGRAM NUMBER OF YOURCHOICE. ";a
   70 IF A<1 OR A>10 THEN GO TO 60
   80 IF A=1 THEN GO TO 170
   90 IF A=2 THEN GO TO 300
  100 IF A=3 THEN GO TO 500
  110 IF A=4 THEN GO TO 730
  120 IF A=5 THEN GO TO 910
  130 IF A=6 THEN GO TO 1110
  140 IF A=7 THEN GO TO 1260
  150 IF A=8 THEN GO TO 1570
  160 IF A=9 THEN GO TO 1810
  170 CLEAR 
  180 PRINT "*****POLYNOMIAL  EVALUATION*****"
  190 PRINT '"INPUT THE INTERVAL OVER WHICH   THE POLYNOMIAL IS TO BE EVALUAT-ED AND THE INCREMENT TO BE USED.":PRINT 
  200 PRINT "E.G., TO EVALUATE OVER THE"'"INTERVAL FROM X=1 TO X=3, INCRE-MENTING BY .01 INPUT 1,3,.01":PRINT 
  210 INPUT A,B,S
  220 FOR X=A TO B STEP S
  230 LET Y=6*X↑4+2*X↑3-10*X↑2-6
  240 PRINT "X=";X;"  Y=";Y
  250 IF Y=0 THEN PRINT X;" IS A ZERO OF THE POLYNOMIAL."
  260 NEXT X
  270 INPUT "ANOTHER RUN ? Y/N";A$
  280 IF A$="Y" THEN GO TO 170
  290 IF A$="N" THEN RUN 
  300 CLEAR :RESTORE 330
  310 PRINT "****GREATEST COMMON DIVISOR ********TRIAL AND  ERROR  METHOD****"
  320 LET k=4:REM INPUT "INPUT NUMBER. ";k
  330 FOR I=1 TO K
  340 READ A:NEXT i
  350 FOR D=1 TO A
  360 FOR I=1 TO K
  370 IF A/D <> INT (A/D) THEN GO TO 400
  380 NEXT I
  390 LET X=D
  400 NEXT D
  410 IF X=1 THEN GO TO 450
  420 PRINT "GREATEST COMMON DIVISOR IS ";
  430 PRINT X
  440 GO TO 470
  450 PRINT "SET OF INTERGERS IS RELATIVELY PRIME."
  460 DATA 39,26,182,286
  470 INPUT "ANOTHER RUN ? Y/N";A$
  480 IF a$="Y" THEN GO TO 300
  490 IF A$="N" THEN RUN 
  500 CLEAR :RESTORE 510
  510 PRINT "******EUCLIDEAN  ALGORITHM******"
  520 READ K,A,B
  530 LET C=2
  540 LET Q= INT (A/B)
  550 LET R=A-Q*B
  560 IF R=1 THEN GO TO 680
  570 IF R=0 THEN GO TO 610
  580 LET A=B
  590 LET B=R
  600 GO TO 540
  610 IF C=K THEN GO TO 660
  620 LET C=C+1
  630 LET A=B
  640 READ B
  650 GO TO 540
  660 PRINT "GREATEST COMMON DIVISOR IS";B
  670 GO TO 700
  680 PRINT "GIVIN INTEGERS ARE RELATIVELY   PRIME."
  690 DATA 4,91,26,169,286
  700 INPUT "ANOTHER RUN ? Y/N";A$
  710 IF A$="Y" THEN GO TO 500
  720 IF A$="N" THEN RUN 
  730 CLEAR 
  740 PRINT "*******PRIME NUMBERS <= N*******"
  750 INPUT "INPUT N. ";N
  760 IF N>1 THEN GO TO 790
  770 PRINT '"  THAT'S TOO EASY.  GIVE ME     ANOTHER ONE."
  780 GO TO 760
  790 PRINT 2
  800 FOR I=2 TO N
  810 LET SI= SQR (I)+.01
  820 FOR J=2 TO SI
  830 LET Q=I/J
  840 IF INT (Q)=Q THEN GO TO 870
  850 NEXT J
  860 PRINT I
  870 NEXT I
  880 INPUT "ANOTHER RUN ? Y/N";A$
  890 IF A$="Y" THEN GO TO 730
  900 IF A$="N" THEN RUN 
  910 CLEAR 
  920 PRINT "*******STANDARD TO METRIC*******"
  930 PRINT '"    F = FEET"'"    I = INCHES"'"    P = POUNDS"'"    Q = QUARTS"
  940 INPUT "INPUT NUMBER OF UNITS, THEN THE MEASUREMENT. ";N,U$
  950 IF U$="F" THEN GO TO 1010
  960 IF U$="I" THEN GO TO 1030
  970 IF U$="P" THEN GO TO 1050
  980 IF U$="Q" THEN GO TO 1070
  990 PRINT "ILLEGAL UNITS"
 1000 GO TO 940
 1010 PRINT N;" FEET=";N*12*2.54/100;" METERS"
 1020 GO TO 1080
 1030 PRINT N;" INCHES=";N*254;" CENTIMETERS"
 1040 GO TO 1080
 1050 PRINT N;" POUNDS=";N*.4535937;" KILOGRAMS"
 1060 GO TO 1080
 1070 PRINT N;" QUARTS=";N*.94635295;" LITERS"
 1080 INPUT "ANOTHER RUN ? Y/N";A$
 1090 IF A$="Y" THEN GO TO 910
 1100 IF A$="N" THEN RUN 
 1110 CLEAR :RESTORE 1110
 1120 PRINT "***CAPACITOR -RESISTOR CIRCUT***"
 1130 READ Q,V,R,C,D
 1140 LET T=0:LET K=10
 1150 PRINT '"TIME","CHARGE":PRINT 
 1160 IF K<10 THEN GO TO 1190
 1170 PRINT INT (T*100+.5)/100,Q
 1180 LET K=Q
 1190 LET Q=Q+(V/R-Q/(R*C))*D
 1200 LET T=T+D:LET K=K+1
 1210 GO TO 1160
 1220 DATA 0,10,2,2,.05
 1230 INPUT "ANOTHER RUN ? Y/N";A$
 1240 IF A$="Y" THEN GO TO 1110
 1250 IF A$="N" THEN RUN 
 1260 CLEAR :RESTORE 1260
 1270 PRINT "*MOLECULAR WEIGHT  OF COMPOUNDS*"
 1280 DIM S$(16):DIM W(16)
 1290 PRINT :PRINT "IN ORDER TO CALCULATE THE MOLEC-ULAR WEIGHT OF YOUR COMPOUND, I WILL ASK YOU FOR THE NUMBER OF  ELEMENTS IN YOUR COMPOUND AND   THEN THE SYMBOL AND QUANTITY OF EACH ELEMENT IN TURN.  FOR EXAM-PLE, WATER WOULD BE INPUT AS:":PRINT 
 1300 PRINT "ELEMENT #1? H,2"
 1310 PRINT "ELEMENT #2? O,1"
 1320 PRINT '
 1330 FOR I=1 TO 16
 1340 READ S$(I),W(I):NEXT I
 1350 INPUT "HOW MANY ELEMENTS IN YOUR"'"COMPOUND? ";N
 1360 PRINT 
 1370 LET WT=0
 1380 FOR I=1 TO N
 1390 PRINT "ELEMENT #";I;
 1400 INPUT E$,C
 1410 FOR J=1 TO 16
 1420 IF E$ <>S$(J) THEN GO TO 1450
 1430 LET WT=WT+W(J)*C
 1440 GO TO 1470
 1450 NEXT J
 1460 PRINT "I DON'T RECOGNIZE ";E$;". TRY    AGAIN.":GO TO 1390
 1470 NEXT I
 1480 PRINT '"THE MOLECULAR WEIGHT IS";WT
 1490 PRINT '
 1500 DATA "O",16,"H",1,"C",12,"N",14,"F",19
 1510 DATA "B",10.8,"P",31,"S",32,"K",39,"CL",35.5
 1520 DATA "MG",24,"NA",23,"FE",55.8,"CA",40
 1530 DATA "AG",107.9,"ZN",65.4
 1540 INPUT "ANOTHER RUN ? Y/N";A$
 1550 IF A$="Y" THEN GO TO 1260
 1560 IF A$="N" THEN RUN 
 1570 CLS 
 1580 PRINT "************GENETICS************"
 1590 DIM M$(2):DIM F$(2)
 1600 PRINT '"     ENTER THE GENOTYPE OF EACH PARENT, NUMBER OF OFFSPRING,     AND IF THE RESULTS OF EACH OFF- SPRING ARE TO BE PRINTED. Y/N"
 1610 PRINT '"EXAMPLE: BR,BL,BL,BL,100,Y"
 1620 INPUT M$(1),M$(2),F$(1),F$(2),N,P$
 1630 LET BL=0
 1640 FOR I=1 TO N
 1650 LET W$=M$(INT (RND*2+1))
 1660 LET X$=F$(INT (RND*2+1))
 1670 LET Y$="BR"
 1680 IF W$="BR" OR X$="BR" THEN GO TO 1710
 1690 LET BL=BL+1
 1700 LET Y$="BL"
 1710 IF P$="Y" THEN PRINT I,W$;",";X$,Y$
 1720 NEXT I
 1730 LET BR=N-BL
 1740 PRINT 
 1750 PRINT "RATIO FOR ";N;" OFFSPRING IS ";BR;": ";BL
 1760 IF BL<2 THEN GO TO 1620
 1770 PRINT "WHICH IS "; INT (BR/BL*10+.05)/10;":1"
 1780 INPUT "ANOTHER RUN ? Y/N";A$
 1790 IF A$="Y" THEN GO TO 1570
 1800 IF A$="N" THEN RUN 
 1810 PAPER 1:INK 6:BORDER 1
 1820 CLS :CLEAR 
 1830 PRINT "     HEAT OF REACTION"
 1840 INPUT "INPUT TEMPERATURE CHANGE  ";T
 1850 INPUT "INPUT GRAMS OR Ml OF WATER  ";L
 1860 INPUT "INPUT GRAMS OF SUBSTANCE  ";G
 1870 INPUT "INPUT MOLAR MASS OF SUBSTANCE  ";S
 1880 PRINT '''"DECIMAL 3 SPACES RIGHT FOR Kcal"
 1890 PRINT "CALORIES          = ";T*L
 1900 PRINT "CALORIES PER MOLE = ";C/M
 1910 PRINT "MOLES OF SUBSTANCE= ";G/S
 1920 INPUT "ANOTHER RUN ? Y/N";A$
 1930 IF A$="Y" THEN GO TO 1810
 1940 IF A$="N" THEN RUN 
 1950 REM 
 1960 SAVE "FILE+" LINE 10

Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.