This program is a weather analysis and logging application that stores meteorological observations in a 90-row by 31-column string array A$(). Each record packs date, high and low temperatures (with sign), barometric pressure, weather condition code, precipitation, snowfall, and wind direction/speed into fixed-width fields within a single array row. The forecast module uses a rule-based decision table matching barometric pressure thresholds, pressure trend (steady/rising/falling), and wind direction to produce plain-language weather predictions. Normal climate data embedded in the listing is attributed to the National Weather Service at Harrisburg, PA (elevation 338 ft), suggesting a specific mid-Atlantic US location. The program uses FAST/SLOW mode switching during the date-search loop at line 3018 to speed up string comparisons across up to 190 records.
Program Analysis
Program Structure
The program is organised as a menu-driven application with a splash/intro subroutine called at startup, then a main menu loop. Control flow is entirely via GOTO and GOSUB; there is only one subroutine (lines 2000–2090). The main functional sections are:
- Initialisation & intro (lines 13–59): variable/array declarations, splash screen subroutine call.
- Main menu (lines 60–130): displays options and dispatches on a single character input.
- Data entry / UPDATE (lines 135–375): guided field-by-field entry of a daily weather record.
- Forecast (lines 380–687): barometric pressure + trend + wind direction rule table.
- Display data (lines 700–750): scrolls all stored records.
- Display normals (lines 900–1040): hardcoded monthly climate normals.
- Search by date (lines 3000–4020): linear scan of array for a matching date.
- Corrections (lines 5000–6010): locate a record by date and re-enter all fields.
- Save (line 9000): saves the program (and thus the in-memory array data).
Data Storage Format
All weather records are stored in a single two-dimensional string array A$(90,31), giving a maximum of 90 records each 31 characters wide. The record counter L tracks how many records have been entered; the hard limit is 190 (checked at line 143), though the array only has 90 rows — this is a latent off-by-one capacity bug.
| Columns | Field | Format |
|---|---|---|
| 1–2 | Month | 2 digits |
| 3–4 | Day | 2 digits |
| 5–6 | Year | 2 digits |
| 7–10 | High temperature | sign + 3 digits (e.g. +076) |
| 11–14 | Low temperature | sign + 3 digits (e.g. -006) |
| 15–19 | Barometric pressure | 5 chars (inches) |
| 20 | Weather condition code | 1 digit (1–7) |
| 21–25 | Precipitation | 5 chars (inches, e.g. 02.75) |
| 26–27 | Snowfall | 2 digits |
| 28–31 | Wind direction + speed | 2-digit direction code + 2-digit speed |
Forecast Rule Table
The forecast section (lines 435–505) implements a classic barometric weather forecasting method using a cascade of IF conditions. Each rule tests three variables: A (barometer reading in inches), B (pressure trend 1–5), and C (wind direction 1–8). Sixteen rules cover combinations of high/low pressure, rising/falling trends, and wind quadrant, mapping to eleven distinct forecast messages. Each message block ends with PAUSE 40000 (maximum pause, effectively waiting for a keypress) then GOTO 60 to return to the main menu.
Notably, no ELSE or default forecast exists: if none of the 16 conditions match the inputs, the program falls through lines 435–505 silently and drops into the first forecast print block at line 600, printing “FAIR, LITTLE IN TEMP” regardless. This is a logic gap rather than intentional design.
FAST/SLOW Mode Usage
The date-search loop at lines 3018–3055 and 5015–5040 calls FAST before iterating over up to L records comparing 4-character string slices. SLOW is restored either when the record is found or after the loop exhausts without a match. This is a practical optimisation for string-intensive searching, since display is not needed during the scan.
Array Slicing as Structured Records
The program makes extensive use of substring slicing on both the input buffer arrays (e.g. B$(1,1 TO 8)) and the main data array. Single-row auxiliary arrays (B$ through K$) act as typed input buffers with fixed widths — a workaround for the lack of structured records. Input is always captured into these fixed-dimension arrays rather than plain string variables, which enforces field-width discipline.
Notable Techniques and Idioms
- Inverse-video text (e.g.
%W%E%A%T%H%E%R%) is used for headers and highlighted prompts throughout. PAUSE 40000is used as a “press any key” wait (maximum pause duration) rather than anINKEY$loop.- The display-all-records section (lines 705–730) calls
SCROLLbefore and after eachPRINT A$(T), producing a double-scroll effect that may be an unintended display artifact. - Line 9000 saves the program with a filename containing an inverse character, functioning as an auto-run save.
- After a correction is made (line 6010), control jumps to line 300 (the data-review/confirmation block) with
X=N, reusing the update confirmation display — a tidy code-reuse pattern.
Bugs and Anomalies
- Array capacity vs. limit mismatch:
A$(90,31)holds 90 rows, but the full check at line 143 triggers atL=190. Entering more than 90 records will cause an array subscript error before the guard fires. - Forecast fall-through: No default branch exists after the rule table; unmatched inputs silently fall into line 600.
- Condition code overlap: Lines 485 and 475 both test
B=4with overlappingCranges (C=3 OR C=2vs.C>=2 AND C<=4), meaning line 475 will always match before line 485 forC=2orC=3. Line 485 is unreachable for those wind codes. - Corrections omit snowfall until line 6000: In the corrections module, the snowfall field input (
A$(N,26 TO 27)) is at line 6000, separated from the logically adjacent wind entry at line 5190 by a jump to line 300 at line 6010 — the structure is correct but the wide line-number gap is potentially confusing. - Misspellings in prose: “MONTHES” (line 2057) and “MANTAINED” (line 2058) are present in the intro text.
Content
Source Code
13 LET X=0
14 LET A=0
15 LET B=0
16 LET C=0
17 LET L=0
18 DIM A$(90,31)
19 DIM B$(1,8)
20 DIM C$(1,4)
25 DIM D$(1,4)
30 DIM E$(1,5)
35 DIM F$(1,1)
40 DIM G$(1,5)
45 DIM H$(1,3)
50 DIM I$(1,4)
55 DIM J$(1,31)
56 DIM K$(1)
59 GOSUB 2000
60 CLS
65 PRINT AT 0,5;"%W%E%A%T%H%E%R% %A%N%A%L%Y%S%I%S"
70 PRINT
75 PRINT AT 5,3;"UPDATE DATA ENTER %U"
80 PRINT AT 7,3;"FORECAST FROM DATA ENTER %F"
85 PRINT AT 9,3;"DISPLAY DATA ENTER %D"
90 PRINT AT 11,3;"DISPLAY NORMALS ENTER %N"
92 PRINT AT 13,3;"TO STOP ENTER %S"
93 PRINT AT 15,3;"SEARCH DATE ENTER %C"
94 PRINT AT 17,3;"CORRECTIONS ENTER %M"
95 PRINT AT 20,0;"%F%U%N%C%T%I%O%N???"
100 INPUT Y$
105 IF Y$="U" THEN GOTO 135
110 IF Y$="F" THEN GOTO 380
115 IF Y$="D" THEN GOTO 700
120 IF Y$="N" THEN GOTO 900
122 IF Y$="C" THEN GOTO 3000
123 IF Y$="M" THEN GOTO 5000
125 IF Y$="S" THEN STOP
130 GOTO 95
135 CLS
140 PRINT " DATA UPDATE"
143 IF L=190 THEN PRINT "FILE FULL"
144 IF L=190 THEN PAUSE 40000
145 IF L=190 THEN GOTO 60
146 PRINT
150 PRINT "ENTER DATE (AS 12-30-83):"
155 INPUT B$(1,1 TO 8)
158 LET L=L+1
160 FOR X=L TO 190
165 LET A$(X,1 TO 2)=B$(1,1 TO 2)
170 LET A$(X,3 TO 4)=B$(1,4 TO 5)
172 LET A$(X,5 TO 6)=B$(1,7 TO 8)
175 PRINT "ENTER HIGH TEMPERATURE (AS +076)"
180 INPUT C$(1,1 TO 4)
185 LET A$(X,7 TO 10)=C$(1,1 TO 4)
190 PRINT "ENTER LOW TEMPERATURE (AS -006)"
195 INPUT D$(1,1 TO 4)
200 LET A$(X,11 TO 14)=D$(1,1 TO 4)
205 PRINT "ENTER BAROMETER (IN INCHES)"
210 INPUT E$(1,1 TO 5)
215 LET A$(X,15 TO 19)=E$(1,1 TO 5)
220 PRINT "ENTER GENERAL WEATHER CONDITION",,"1=FAIR",,"2=CLOUDY",,"3=RAIN"
223 PRINT ,"4=SNOW",,"5=THUNDERSHOWERS","6=SNOW FLURRIES",,"7=HEAVY RAIN"
225 INPUT F$(1,1)
230 LET A$(X,20)=F$(1,1)
235 PRINT "ENTER PRECIPITATION (INCHES)"
240 PRINT "AS:02.75"
245 INPUT G$(1,1 TO 5)
248 LET A$(X,21 TO 25)=G$(1,1 TO 5)
250 PRINT "SNOWFALL AMOUNT (AS 07)"
255 INPUT H$(1,1 TO 2)
258 LET A$(X,26 TO 27)=H$(1,1 TO 2)
260 CLS
265 PRINT "ENTER WIND DIRECTION AND SPEED:"
270 PRINT "USE THIS CODE:","01=N",,"02=NE",,"03=E",,"04=SE",,"05=S",,"06=SW"
273 PRINT ,"07=W",,"08=NW"
275 PRINT
280 PRINT "ENTER DIRECTION AND SPEED","AS FOUR DIGIT NUMBER ""0312"""
285 INPUT I$(1,1 TO 4)
290 LET A$(X,28 TO 31)=I$(1,1 TO 4)
295 CLS
300 PRINT "DATE: ";A$(X,1 TO 6)
305 PRINT "HI TEMP: ";A$(X,7 TO 10)
310 PRINT "LO TEMP: ";A$(X,11 TO 14)
315 PRINT "BAROMETER: ";A$(X,15 TO 19)
320 PRINT "CONDITIONS: ";A$(X,20)
330 PRINT "PRECIPITATION: ";A$(X,21 TO 25)
335 PRINT "SNOWFALL: ";A$(X,26 TO 27)
340 PRINT "WINDS: ";A$(X,28 TO 31)
342 PRINT "USE THIS CODE:","01=N",,"02=NE",,"03=E",,"04=SE",,"05=S",,"06=SW"
343 PRINT ,"07=W",,"08=NW"
345 PRINT
350 PRINT "%I%S% %T%H%I%S% %C%O%R%R%E%C%T% %?"
355 INPUT Z$
360 IF Z$="N" THEN GOTO 135
365 LET L=X
370 IF Z$="Y" THEN CLS
375 IF Z$="Y" THEN GOTO 65
380 CLS
385 PRINT " FORECAST"
390 PRINT "ENTER BAROMETRIC PRESSURE:"
395 INPUT A
400 PRINT
405 PRINT "IS BAROMETER: ","1. STEADY",,"2. SLOW RISE",,"3. RAPID RISE"
406 PRINT ,"4. SLOW FALL",,"5. RAPID FALL"
407 PRINT "RAPID CHANGE IS ANY CHANGE ","IN EXCESS OF 0.06 PER HOUR."
410 INPUT B
415 PRINT
420 PRINT "WIND FROM:"
425 PRINT ,"1=N",,"2=NE",,"3=E",,"4=SE",,"5=S",,"6=SW",,"7=W",,"8=NW"
430 INPUT C
433 CLS
435 IF A>=30.2 AND B=4 AND C>=6 AND C<=8 THEN GOTO 625
440 IF A>=30.2 AND B=1 AND C>=6 AND C<=8 THEN GOTO 620
445 IF A>=30.1 AND B=1 AND C>=6 AND C<=8 THEN GOTO 600
450 IF A>=30.1 AND B=3 AND C>=6 AND C<=8 THEN GOTO 605
455 IF A>=30.1 AND B=4 AND C>=6 AND C<=8 THEN GOTO 610
460 IF A>=30.1 AND B=5 AND C>=6 AND C<=8 THEN GOTO 615
465 IF A>=30.1 AND B=4 AND (C=4 OR C=5) THEN GOTO 630
470 IF A>=30.1 AND B=5 AND (C=4 OR C=5) THEN GOTO 635
475 IF A>=30.1 AND B=4 AND C>=2 AND C<=4 THEN GOTO 640
480 IF A>=30.1 AND B=5 AND C>=2 AND C<=4 THEN GOTO 645
485 IF A>=30.1 AND B=4 AND (C=3 OR C=2) THEN GOTO 650
490 IF A>=30.1 AND B=5 AND (C=3 OR C=2) THEN GOTO 655
492 IF A<=29.8 AND B=5 AND C>=1 AND C<=3 THEN GOTO 680
493 IF A<=29.8 AND B=5 AND C>=3 AND C<=5 THEN GOTO 675
494 IF A<=29.8 AND B=3 THEN GOTO 685
495 IF A<=30.1 AND B=4 AND C<=4 AND C>=2 THEN GOTO 660
500 IF A<=30.1 AND B=5 AND C<=4 AND C>=2 THEN GOTO 665
505 IF A<=30.1 AND B=2 AND (C=5 OR C=6) THEN GOTO 670
600 PRINT "FAIR, LITTLE IN TEMP","FOR NEXT DAY OR TWO."
601 PAUSE 40000
602 GOTO 60
605 PRINT "FAIR TODAY, RAINY AND WARMER","WITHIN 48 HOURS"
606 PAUSE 40000
607 GOTO 60
610 PRINT "WARMER, RAIN WITHIN 18 TO 24","HOURS"
616 PAUSE 40000
617 GOTO 60
620 PRINT "CONTINUED FAIR WITH LITTLE","OR NO CHANGE IN TEMPERATURE"
621 PAUSE 40000
622 GOTO 60
625 PRINT "FAIR AND WARMER FOR NEXT 48 HOURS"
626 PAUSE 40000
627 GOTO 60
630 PRINT "RAIN WITHIN 24 HOURS"
631 PAUSE 40000
632 GOTO 60
635 PRINT "WINDY, WITH RAIN WITHIN 12","TO 24 HOURS"
636 PAUSE 40000
637 GOTO 60
640 PRINT "RAIN IN 12 TO 18 HOURS"
641 PAUSE 40000
642 GOTO 60
645 PRINT "WINDY AND RAIN WITHIN 12 HOURS"
646 PAUSE 40000
647 GOTO 60
650 PRINT "IN SUMMER WITH LIGHT WINDS: ","RAIN MAY NOT FALL FOR SEVERAL","DAYS"
651 PRINT "IN WINTER: RAIN WITHIN 24 HOURS"
652 PAUSE 40000
653 GOTO 60
655 PRINT "IN SUMMER RAIN LIKELY WITHIN","12 TO 24 HOURS"
656 PRINT ,,"IN WINTER: RAIN OR SNOW WITH INCREASING WINDS"
657 PAUSE 40000
658 GOTO 60
660 PRINT "RAIN FOR NEXT DAY OR TWO"
661 PAUSE 40000
662 GOTO 60
665 PRINT "RAIN, WITH HIGH WINDS FOLLOWED","WITHIN 24 HOURS BY CLEARING "
666 PRINT "AND TURNING COLDER"
667 PAUSE 40000
668 GOTO 60
670 PRINT "CLEARING WITHIN A FEW HOURS","FAIR FOR NEXT SEVERAL DAYS"
671 PAUSE 40000
672 GOTO 60
675 PRINT "%S%E%V%E%R%E% %S%T%O%R%M% %W%A%R%N%I%N%G","WINDY,WITH RAIN OR SNOW IMMINENT"
676 PRINT ,,"FOLLOWED WITHIN 24 HOURS BY","CLEARING AND COLDER"
677 PAUSE 40000
678 GOTO 60
680 PRINT "%S%E%V%E%R%E% %S%T%O%R%M% %W%A%R%N%I%N%G","SEVERE NORTHEAST GALES"
681 PRINT ,,"HEAVY RAIN OR SNOW, FOLLOWED IN WINTER BY A COLD WAVE"
682 PAUSE 40000
683 GOTO 60
685 PRINT "CLEARING AND COLDER"
686 PAUSE 40000
687 GOTO 60
700 CLS
705 FOR T=1 TO L
706 SCROLL
710 PRINT A$(T)
720 SCROLL
730 NEXT T
740 PAUSE 200
750 GOTO 60
900 CLS
905 PRINT " %W%E%A%T%H%E%R% %N%O%R%M%S"
925 PRINT
930 PRINT " TEMP"
935 PRINT " HI LO MO RAIN SNOW"
940 PRINT "J 38 23 30 2.83 9.1"
945 PRINT "F 41 24 32 2.70 9.6"
950 PRINT "M 51 31 41 3.19 6.5"
955 PRINT "A 64 42 53 3.02 0.3"
960 PRINT "M 75 52 63 3.61 0.0"
965 PRINT "J 83 61 72 3.61 0.0"
970 PRINT
975 PRINT "J 87 65 76 3.61 0.0"
980 PRINT "A 85 63 74 3.76 0.0"
985 PRINT "S 78 56 67 3.21 0.0"
990 PRINT "O 67 45 56 2.82 0.1"
995 PRINT "N 53 35 44 2.66 2.1"
1000 PRINT "D 40 25 33 2.94 7.7"
1005 PRINT
1010 PRINT "YR 63 43 53 37.96"
1015 PRINT
1020 PRINT "DATA FROM NWS HBG.,PA."
1025 PRINT " ELEVATION 338 FT."
1030 PAUSE 40000
1040 GOTO 60
2000 CLS
2001 FOR I=1 TO 10
2002 PRINT
2003 NEXT I
2005 PRINT " %W%E%A%T%H%E%R% %A%N%A%L%Y%S%I%S"
2040 PAUSE 400
2050 CLS
2055 PRINT "THIS PROGRAM IS DESIGNED TO","STORE A LIMITED AMOUNT OF DATA"
2056 PRINT "IN THE FILE PORTION OF THE","PROGRAM. IT IS SUGGESTED"
2057 PRINT "THAT FOR STORAGE OF MORE THAN ","SIX MONTHES A WEATHER FILE BE"
2058 PRINT "MANTAINED."
2060 PRINT
2065 PRINT "THIS PROGRAM WILL OFFER A","FORECAST OF EXPECTED LOCAL"
2066 PRINT "WEATHER CONDITIONS, USING","BAROMETRIC PRESSURE AND WIND"
2067 PRINT "DIRECTION",,,,"YOU WILL BE SURPRISED AT"
2068 PRINT "THE ACCURACY OF THIS METHOD,","YET IT IS BASED ON SOUND"
2069 PRINT "SCIENTIFIC PRINCIPLES."
2070 PRINT
2075 PRINT "%P%R%E%S%S% %A%N%Y% %K%E%Y% %T%O% %C%O%N%T%I%N%U%E"
2080 PAUSE 40000
2085 CLS
2090 RETURN
3000 CLS
3010 PRINT "ENTER DATE (AS 12-05-83)"
3015 INPUT B$(1,1 TO 8)
3018 FAST
3020 LET C$(1,1 TO 2)=B$(1,1 TO 2)
3025 LET C$(1,3 TO 4)=B$(1,4 TO 5)
3030 FOR A=1 TO L
3035 IF C$(1,1 TO 4)=A$(A,1 TO 4) THEN GOTO 3050
3040 NEXT A
3042 SLOW
3045 PRINT "%D%A%T%E% %N%O%T% %F%O%U%N%D"
3046 PAUSE 40000
3047 GOTO 60
3050 CLS
3055 SLOW
3066 PRINT "DATE: ";A$(A,1 TO 6)
3070 PRINT "HI TEMP: ";A$(A,7 TO 10)
3075 PRINT "LO TEMP: ";A$(A,11 TO 14)
3080 PRINT "BAROMETER: ";A$(A,15 TO 19)
3085 PRINT "CONDITION: ";A$(A,20)
3090 PRINT "PRECIPITATION: ";A$(A,21 TO 25)
3095 PRINT "SNOWFALL: ";A$(A,26 TO 27)
4000 PRINT "WINDS: ";A$(A,28 TO 31)
4010 PAUSE 40000
4020 GOTO 60
5000 CLS
5005 PRINT "ENTER DATE TO CHANGE:"
5010 INPUT B$(1,1 TO 8)
5011 LET C$(1,1 TO 2)=B$(1,1 TO 2)
5012 LET C$(1,3 TO 4)=B$(1,4 TO 5)
5015 FAST
5020 FOR N=1 TO L
5025 IF A$(N,1 TO 4)=C$(1,1 TO 4) THEN GOTO 5100
5030 NEXT N
5040 SLOW
5050 PRINT "DATE NOT IN FILE"
5055 PAUSE 40000
5060 GOTO 60
5100 CLS
5110 PRINT "ENTER: "
5120 PRINT TAB 5;"DATE (AS 6 DIGITS)"," (120583)"
5125 INPUT A$(N,1 TO 6)
5130 PRINT TAB 5;"HI TEMP"
5135 INPUT A$(N,7 TO 10)
5140 PRINT TAB 5;"LOW TEMP"
5145 INPUT A$(N,11 TO 14)
5150 PRINT TAB 5;"BAROMETER"
5155 INPUT A$(N,15 TO 19)
5160 PRINT TAB 5;"CONDITION"
5165 PRINT ,"1. FAIR",,"2. CLOUDY",,"3. RAIN",,"4. SNOW",,"5. THUNDERSHOWERS"
5167 PRINT ,"6. SNOW FLURRIES","7. HEAVY RAIN"
5170 INPUT A$(N,20)
5175 PRINT TAB 5;"RAIN"
5180 INPUT A$(N,21 TO 25)
5185 PRINT TAB 5;"WINDS"
5190 INPUT A$(N,28 TO 31)
5195 PRINT TAB 5;"SNOWFALL"
6000 INPUT A$(N,26 TO 27)
6005 LET X=N
6007 CLS
6010 GOTO 300
9000 SAVE "1024%3"
9010 RUN
Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.
