Calculator

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

Calculator for general use.

Appears on

Library tape from the Sinclair Computer Users Society (SINCUS).

Gallery

Calculator

Source Code

   90 REM "CALCULATOR"
  100 REM INSTRUCTIONS:
  110 REM 1)DEFINE VARIABLES
  120 REM 2)DEFINE LINES
  130 REM 3)GOTO RESET TABLE
  140 REM 4)MAKE SURE 10 COLUMNS            ARE RESET!
  150 REM 5)NOW PRINT TABLE!
  160 REM 6)CHANGE FORMULAE OR              SAVE PROGRAM
  170 REM 7)CUSS AT AUTHOR!!!!!
  180 REM 
  190 REM 
  200 REM 
 1000 REM ***********************
 1010 REM MENU
 1020 REM ***********************
 1030 CLS : INK 0: PAPER 7: PRINT "         CALCULATOR"
 1040 PRINT '"1)INITIALIZE"
 1050 PRINT '"2)PRINT TABLE"
 1060 PRINT '"3)RESET TABLE"
 1070 PRINT '"4)DEFINE VARIABLES"
 1080 PRINT '"5)DEFINE LINES"
 1090 PRINT '"6)DISPLAY COLUMN VARIABLES"
 1100 PRINT '"7)STOP"
 1110 INPUT Z$: CLS 
 1120 IF Z$="1" THEN GO SUB 1220
 1130 IF Z$="2" THEN GO SUB 1300
 1140 IF Z$="3" THEN GO SUB 1400
 1150 IF Z$="4" THEN GO SUB 1690
 1160 IF Z$="5" THEN GO SUB 1810
 1170 IF Z$="6" THEN GO SUB 1920
 1180 IF Z$="7" THEN GO TO 1200
 1190 CLS : GO TO 1030
 1200 PRINT AT 10,10;"CALCULATOR": INPUT "HAVE YOU ENTERED NEW DATA YOU   WISH TO SAVE? (Y/N) ";Q$: IF Q$="Y" THEN SAVE "CALCULATOR": BEEP 1,40: PRINT "REWIND THEN ANY KEY TO VERIFY.": PAUSE 0: VERIFY "CALCULATOR": PRINT "VERIFIED"
 1210 STOP 
 1220 REM ***********************
 1230 REM INITIALIZE
 1240 REM ***********************
 1250 DIM A$(20,10): DIM B$(20,10): DIM C$(20,50): DIM E$(20,50)
 1260 DIM B(20,10): DIM D(20,10)
 1270 LET LINES=0: LET VARIABLES=0
 1290 RETURN 
 1300 REM ***********************
 1310 REM PRINT TABLE
 1320 REM ***********************
 1330 INPUT "COLUMN FOR DISPLAY? (0=QUIT)";COLUMN: PAPER 7: IF COLUMN=0 THEN PAPER 7: RETURN 
 1340 CLS : PRINT "LINES      FIGURES"
 1350 FOR I=1 TO LINES: PAPER (5+2*(I/2=INT (I/2))): PRINT A$(I);" ";
 1360 LET M$=STR$ D(I,COLUMN): IF LEN M$>10 THEN PRINT M$( TO 10): GO TO 1380
 1370 PRINT M$
 1380 NEXT I
 1390 GO TO 1330
 1400 REM ***********************
 1410 REM RESET TABLE
 1420 REM ***********************
 1430 INPUT "HOW MANY COLUMNS? ";COLUMNS
 1440 FOR K=1 TO LINES: LET F$=C$(K): GO SUB 1490: LET E$(K)=G$: NEXT K
 1450 FOR I=1 TO LINES: FOR J=1 TO COLUMNS
 1460 LET D(I,J)=VAL E$(I)
 1470 NEXT J: NEXT I
 1480 RETURN 
 1490 REM ***********************
 1500 REM IDENTIFY VARIABLES
 1510 REM ***********************
 1520 LET G$="": LET V$=""
 1530 FOR I=1 TO LEN F$: IF F$(I)=" " THEN GO TO 1610
 1540 IF F$(I)>="A" AND F$(I)<="Z" THEN LET V$=V$+F$(I): GO TO 1600
 1550 IF LEN V$>=4 THEN LET I=I: IF V$(1 TO 4)="LINE" AND (F$(I)>="0" AND F$(I)<="9") THEN LET V$=V$+F$(I): GO TO 1600
 1560 IF LEN V$>=4 THEN LET I=I: IF V$(1 TO 4)="LINE" AND LEN V$=4 AND ((F$(I)<"0" OR F$(I)>"Z") OR (F$(I)<"A" AND F$(I)>"9")) THEN PRINT "LINE UNDEFINED": PAUSE 200: RETURN 
 1570 IF LEN V$>=4 THEN LET I=I: IF V$(1 TO 4)="LINE" AND (F$(I)<"A" OR F$(I)>"Z") THEN GO SUB 1630: LET V$="": LET G$=G$+F$(I): GO TO 1600
 1580 IF V$<>"" AND (F$(I)<"A" OR F$(I)>"Z") THEN GO SUB 1630: LET G$=G$+F$(I): LET V$="": GO TO 1600
 1590 LET G$=G$+F$(I)
 1600 NEXT I
 1610 IF LEN V$>0 THEN GO SUB 1630
 1620 RETURN 
 1630 REM ***********************
 1640 REM EVALUATE
 1650 REM ***********************
 1660 IF LEN V$>=4 THEN LET I=I: IF V$(1 TO 4)="LINE" THEN LET G$=G$+"D("+V$(5 TO )+",J)": RETURN 
 1670 FOR J=1 TO VARIABLES: IF V$<>B$(J,1 TO LEN V$) THEN NEXT J: PRINT "VARIABLE ";V$;" NOT FOUND.": PAUSE 200: LET IND=0: RETURN 
 1680 LET G$=G$+"B("+STR$ J+",J)": RETURN 
 1690 REM ***********************
 1700 REM DEFINE VARIABLES
 1710 REM ***********************
 1720 CLS : FOR I=1 TO VARIABLES: PRINT I;") ";B$(I): NEXT I
 1730 INPUT "1)EXISTING   2)NEW   3)QUIT ";Q$: IF Q$="3" THEN RETURN 
 1740 IF Q$="1" THEN INPUT "NUMBER? ";N: GO TO 1760
 1750 IF Q$="2" THEN INPUT "VARIABLE NAME? ";N$: LET VARIABLES=VARIABLES+1: LET N=VARIABLES: LET B$(VARIABLES)=N$
 1760 CLS : PRINT B$(N): FOR I=1 TO 10: PRINT I;") ";B(N,I): NEXT I
 1770 INPUT "NUMBER ""ZZZ"" QUIT ""DDD"" DELETE  ";Q$: IF Q$="ZZZ" THEN GO TO 1720
 1780 IF Q$="DDD" THEN FOR I=N TO VARIABLES-1: LET B$(I)=B$(I+1): FOR J=1 TO 10: LET B(I,J)=B(I+1,J): NEXT J: NEXT I: LET B$(VARIABLES)="": FOR I=1 TO 10: LET B(VARIABLES,I)=0: NEXT I: LET VARIABLES=VARIABLES-1: RETURN 
 1790 INPUT "VALUE? (""X"" EQUAL TO COLUMN ONE) ";N$: IF N$="X" THEN LET B(N,VAL Q$)=B(N,1): GO TO 1760
 1800 LET B(N,VAL Q$)=VAL N$: GO TO 1760
 1810 REM ***********************
 1820 REM DEFINE LINES
 1830 REM ***********************
 1840 CLS : PRINT "            LINES"
 1850 FOR I=1 TO LINES: PRINT I;")";""+A$(I)+"";C$(I): NEXT I
 1860 INPUT "1)EXISTING   2)NEW   3)DELETE   4)QUIT";Q$: IF Q$="4" THEN RETURN 
 1870 IF Q$="2" THEN INPUT "LINE TITLE? ";N$: LET LINES=LINES+1: LET N=LINES: LET A$(LINES)=N$: INPUT "FORMULA? ";F$: LET C$(LINES)=F$: GO SUB 1490: LET E$(N)=G$: GO TO 1840
 1880 IF Q$="1" THEN INPUT "NUMBER? ";N: INPUT "NEW TITLE? (Y/N) ";T$: IF T$="Y" THEN INPUT "SPECIFY NEW TITLE: ";T$: LET A$(N)=T$
 1890 IF Q$="1" THEN INPUT "NEW FORMULA? (Y/N) ";T$: IF T$="Y" THEN INPUT "SPECIFY NEW FORMULA: ";F$: LET C$(N)=F$: GO SUB 1490: LET E$(N)=G$: GO TO 1840
 1900 IF Q$="3" THEN INPUT "NUMBER? ";N: FOR I=N TO LINES-1: LET A$(I)=A$(I+1): LET C$(I)=C$(I+1): NEXT I: LET A$(LINES)="": LET C$(LINES)="": LET LINES=LINES-1
 1910 RETURN 
 1920 REM ***********************
 1930 REM DISPLAY COLUMN
 1940 REM ***********************
 1950 CLS : INPUT "WHICH COLUMN? (0 TO QUIT) ";N: IF N=0 THEN RETURN 
 1960 CLS : PRINT "COLUMN ";N
 1970 FOR I=1 TO VARIABLES: PRINT I;") ";B$(I);" ";B(I,N): NEXT I
 1980 INPUT "NUMBER FOR AMENDMENT ""ZZZ"" QUIT ";Q$: IF Q$="ZZZ" THEN GO TO 1950
 1990 INPUT "NEW VALUE FOR VARIABLE? ";R: LET B(VAL Q$,N)=R: GO TO 1960

People

No people associated with this content.

Scroll to Top