Weather Analyst

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

This program is a weather data logging and forecasting tool that stores up to 190 daily weather records in a 190×31 character string array, with each record encoding date, high/low temperature, barometric pressure, weather condition code, precipitation, snowfall, and wind direction/speed in fixed-width substrings. The forecasting module uses a rule-based decision table driven by current barometric pressure, its trend (steady/rising/falling), and wind direction to generate text forecasts — including FLASH-highlighted severe storm warnings with multi-note BEEP alerts. A date-search function (GO TO 3000) scans the array by matching the first four characters of each record against an entered date. The normals table hardcoded at lines 940–1010 reflects NWS climatological data for Los Angeles, CA at 270 ft elevation. The program requires entry via GO TO 59 rather than RUN to avoid reinitializing the data array.


Program Analysis

Program Structure

The program is organized into distinct functional sections accessed from a central menu at lines 60–130. Initialization occurs at lines 5–56, and the intro splash screen is handled by the subroutine at line 2000. The REM at line 2 warns users to enter via GO TO 59 rather than RUN — this is because RUN would re-execute the DIM statements and destroy any data already stored in the arrays.

  • Lines 59–130: Initialization call and main menu dispatch
  • Lines 135–375: Data entry / update module (“U”)
  • Lines 380–505, 600–687: Barometric forecast engine (“F”)
  • Lines 700–750: Data display module (“D”)
  • Lines 900–1040: Climatological normals display (“N”)
  • Lines 2000–2090: Intro splash screen subroutine
  • Lines 3000–4020: Date search module (“C”)
  • Lines 5000–6010: Record correction module (“M”)

Data Storage Design

All weather records are packed into A$(190,31), a two-dimensional string array of 190 rows by 31 characters. Each row stores one day’s data in fixed-width fields:

ColumnsFieldFormat
1–2MonthMM
3–4DayDD
5–6YearYY
7–10High temperature+076 / -006
11–14Low temperature+076 / -006
15–19Barometer (inches)5 chars
20Condition code1 digit (1–7)
21–25Precipitation02.75
26–27Snowfall07
28–31Wind dir. + speed4 digits (e.g. 0312)

The variable L tracks the current record count (high-water mark). Date entry uses the helper arrays B$ through J$ as typed single-row buffers for INPUT, which are then copied into the appropriate columns of A$. This is a common Spectrum BASIC technique because INPUT cannot directly target a substring slice of a 2D array.

Forecast Engine

The forecasting section (lines 380–505) collects three numeric inputs — barometric pressure A, trend code B (1=steady through 5=rapid fall), and wind direction code C (1–8) — then evaluates a cascade of IF conditions that map combinations onto forecast message lines (600–687). This is essentially a hand-coded lookup table implementing traditional barometric forecasting rules.

If no condition matches (lines 435–505), execution falls through to line 600, which prints a fair-weather message. This is a latent bug: any unmatched input combination silently produces the “FAIR, LITTLE CHANGE” message rather than an error or a “no match” notice.

Severe weather conditions (lines 675 and 680) produce multi-step alerts: FLASH 1 headings, a three-note ascending BEEP sequence, and descriptive follow-up text, before a long PAUSE 40000 hold.

Date Search and Correction

The date search (lines 3000–4020) strips the dashes from the entered date string using substring slicing into C$ (producing a 4-character MMDD key), then linearly scans A$(A,1 TO 4) for a match. The correction module (lines 5000–6010) performs an identical search using loop variable N, then jumps to line 5100 to allow field-by-field overwriting of the matched record, before redirecting to line 300 to confirm the changes.

Notable Techniques and Idioms

  • PAUSE 40000 is used throughout as an indefinite hold (approx. 6.5 minutes at 50 Hz), effectively waiting for a keypress to time out naturally — a common Spectrum idiom.
  • The intro subroutine at line 2000 is the only true GO SUB/RETURN in the program; all other branching uses GO TO.
  • The FOR X=L TO 190 loop at line 160 is misleading — only the first iteration at X=L (after L=L+1) is used for data entry; there is no logic within the loop to handle multiple entries per pass, and the loop exits via GO TO 65 at line 375, not via NEXT X.
  • Lines 706 and 720 are blank (empty statement lines), a common artifact of program editing that wastes a small amount of memory.
  • The display module (lines 700–750) prints entire rows of A$ with PRINT A$(T) — this works because each row is 31 characters, fitting within the 32-column display width.

Bugs and Anomalies

  • Line 190 prints “TEMERATURE” — a typo for “TEMPERATURE”.
  • Line 2057 prints “MONTHES” — a misspelling of “MONTHS”.
  • Line 2065 prints “FORCAST” — a misspelling of “FORECAST”.
  • The correction module (line 5185–6000) inputs wind data before snowfall, reversing the logical order compared to the original entry form; this is cosmetic but could confuse users.
  • Variables A, B, and C are initialized to 0 at lines 6–8 but are later reused as numeric variables in the forecast engine (lines 395–430) and as loop counters in the date search (lines 3030, 5020). This works correctly since the numeric usage always follows initialization by INPUT, but it is a risky naming overlap with the string arrays A$C$.
  • The forecast decision chain has a gap: inputs with pressure between 29.8 and 30.1 and certain wind/trend combinations reach line 600 unhandled.

Content

Appears On

Related Products

Related Articles

Related Content

Image Gallery

Weather Analyst

Source Code

    1 REM "WX LA"
    2 REM DO NOT USE "RUN"-USE GOTO 59
    5 LET X=0
    6 LET A=0
    7 LET B=0
    8 LET C=0
    9 LET L=0
   10 DIM A$(190,31)
   15 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 GO SUB 2000
   60 BORDER 0: PAPER 1: INK 7: CLS 
   65 PRINT AT 0,5;"WEATHER ANALYSIS "
   66 BEEP .2,55
   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;"FUNCTION???"
  100 INPUT Y$
  102 BEEP .05,40
  105 IF Y$="U" THEN GO TO 135
  110 IF Y$="F" THEN GO TO 380
  115 IF Y$="D" THEN GO TO 700
  120 IF Y$="N" THEN GO TO 900
  122 IF Y$="C" THEN GO TO 3000
  123 IF Y$="M" THEN GO TO 5000
  125 IF Y$="S" THEN STOP 
  130 GO TO 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 GO TO 60
  146 PRINT 
  150 PRINT "ENTER DATE (AS 12-30-82):"
  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 TEMERATURE (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 "IS THIS CORRECT?"
  355 INPUT Z$
  360 IF Z$="N" THEN GO TO 145
  365 LET L=X
  370 IF Z$="Y" THEN CLS 
  375 IF Z$="Y" THEN GO TO 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 GO TO 625
  440 IF A>=30.2 AND B=1 AND C>=6 AND C<=8 THEN GO TO 620
  445 IF A>=30.1 AND B=1 AND C>=6 AND C<=8 THEN GO TO 600
  450 IF A>=30.1 AND B=3 AND C>=6 AND C<=8 THEN GO TO 605
  455 IF A>=30.1 AND B=4 AND C>=6 AND C<=8 THEN GO TO 610
  460 IF A>=30.1 AND B=5 AND C>=6 AND C<=8 THEN GO TO 615
  465 IF A>=30.1 AND B=4 AND (C=4 OR C=5) THEN GO TO 630
  470 IF A>=30.1 AND B=5 AND (C=4 OR C=5) THEN GO TO 635
  475 IF A>=30.1 AND B=4 AND C>=2 AND C<=4 THEN GO TO 640
  480 IF A>=30.1 AND B=5 AND C>=2 AND C<=4 THEN GO TO 645
  485 IF A>=30.1 AND B=4 AND (C=3 OR C=2) THEN GO TO 650
  490 IF A>=30.1 AND B=5 AND (C=3 OR C=2) THEN GO TO 655
  492 IF A<=29.8 AND B=5 AND C>=1 AND C<=3 THEN GO TO 680
  493 IF A<=29.8 AND B=5 AND C>=3 AND C<=5 THEN GO TO 675
  494 IF A<=29.8 AND B=3 THEN GO TO 685
  495 IF A<=30.1 AND B=4 AND C<=4 AND C>=2 THEN GO TO 660
  500 IF A<=30.1 AND B=5 AND C<=4 AND C>=2 THEN GO TO 665
  505 IF A<=30.1 AND B=2 AND (C=5 OR C=6) THEN GO TO 670
  600 PRINT "FAIR, LITTLE CHANGE IN TEMP","FOR NEXT DAY OR TWO."
  601 PAUSE 40000
  602 GO TO 60
  605 PRINT "FAIR TODAY, RAINY AND WARMER","WITHIN 48 HOURS."
  606 PAUSE 40000
  607 GO TO 60
  610 PRINT "WARMER, RAIN WITHIN 18 TO 24","HOURS."
  616 PAUSE 40000
  617 GO TO 60
  620 PRINT "CONTINUED FAIR WITH LITTLE","OR NO CHANGE IN TEMPERATURE."
  621 PAUSE 40000
  622 GO TO 60
  625 PRINT "FAIR AND WARMER FOR NEXT 48 HOURS."
  626 PAUSE 40000
  627 GO TO 60
  630 PRINT "RAIN WITHIN 24 HOURS."
  631 PAUSE 40000
  632 GO TO 60
  635 PRINT "WINDY, WITH RAIN WITHIN 12","TO 24 HOURS."
  636 PAUSE 40000
  637 GO TO 60
  640 PRINT "RAIN IN 12 TO 18 HOURS."
  641 PAUSE 40000
  642 GO TO 60
  645 PRINT "WINDY AND RAIN WITHIN 12 HOURS."
  646 PAUSE 40000
  647 GO TO 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 GO TO 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 GO TO 60
  660 PRINT "RAIN FOR NEXT DAY OR TWO."
  661 PAUSE 40000
  662 GO TO 60
  665 PRINT "RAIN, WITH HIGH WINDS FOLLOWED","WITHIN 24 HOURS BY CLEARING "
  666 PRINT "AND TURNING COLDER."
  667 PAUSE 40000
  668 GO TO 60
  670 PRINT "CLEARING WITHIN A FEW HOURS,","FAIR FOR NEXT SEVERAL DAYS."
  671 GO TO 60
  675 PAPER 7: INK 2: FLASH 1: PRINT "SEVERE STORM WARNING": FLASH 0: PAPER 1: INK 7: PRINT "WINDY, WITH RAIN OR SNOW"," IMMINENT"
  676 BEEP .2,20: BEEP .2,25: BEEP .2,30: PRINT "FOLLOWED WITHIN 24 HOURS BY","CLEARING AND COLDER TEMPS."
  677 PAUSE 40000
  678 GO TO 60
  680 PAPER 7: INK 2: FLASH 1: PRINT "SEVERE STORM WARNING": FLASH 0: PAPER 1: INK 7: PRINT "SEVERE NORTHEAST GALES"
  681 BEEP .2,20: BEEP .2,25: BEEP .2,30: PRINT "HEAVY RAIN OR SNOW, FOLLOWED IN WINTER BY A COLD WAVE"
  682 PAUSE 40000
  683 GO TO 60
  685 PRINT "CLEARING AND COLDER."
  686 PAUSE 40000
  687 GO TO 60
  700 CLS 
  705 FOR T=1 TO L
  706 
  710 PRINT A$(T)
  720 
  730 NEXT T
  740 PAUSE 200
  750 GO TO 60
  900 CLS 
  905 PRINT "      WEATHER NORMS"
  925 PRINT 
  930 PRINT "      TEMP"
  935 PRINT "  HI LO MO  RAIN   SNOW"
  940 PRINT "J 66 46 56   3.06     TR"
  945 PRINT "F 67 48 58   3.07     TR"
  950 PRINT "M 68 49 59   2.55    0.0"
  955 PRINT "A 70 52 61   1.07    0.0"
  960 PRINT "M 73 56 64   0.32    0.0"
  965 PRINT "J 76 59 68   0.06    0.0"
  970 PRINT 
  975 PRINT "J 82 63 73   0.01    0.0"
  980 PRINT "A 83 64 74   0.05    0.0"
  985 PRINT "S 82 62 72   0.23    0.0"
  990 PRINT "O 78 58 68   0.50    0.0"
  995 PRINT "N 73 52 62   1.37    0.0"
 1000 PRINT "D 68 48 58   2.62     TR"
 1005 PRINT 
 1010 PRINT "YR 74 55 64 14.91"
 1015 PRINT 
 1020 PRINT "DATA FROM NWS L.A.,CA."
 1025 PRINT "           ELEVATION 270 FT."
 1030 PAUSE 40000
 1040 GO TO 60
 2000 BORDER 0: PAPER 0: INK 7: CLS 
 2001 FOR I=1 TO 10
 2002 PRINT 
 2003 NEXT I
 2005 PRINT "        WEATHER ANALYSIS "
 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 "MAINTAINED."
 2060 PRINT 
 2065 PRINT "THIS PROGRAM WILL OFFER A","FORCAST 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 "PRESS ANY KEY TO CONTINUE"
 2080 PAUSE 40000
 2085 CLS 
 2090 RETURN 
 3000 CLS 
 3010 PRINT "ENTER DATE (AS 12-05-82)"
 3015 INPUT B$(1,1 TO 8)
 3018 
 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 GO TO 3050
 3040 NEXT A
 3042 
 3045 FLASH 1: PRINT "DATE NOT FOUND": FLASH 0
 3046 PAUSE 40000
 3047 GO TO 60
 3050 CLS 
 3055 
 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 GO TO 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 
 5020 FOR N=1 TO L
 5025 IF A$(N,1 TO 4)=C$(1,1 TO 4) THEN GO TO 5100
 5030 NEXT N
 5040 
 5050 FLASH 1: PRINT "DATE NOT IN FILE": FLASH 0
 5055 PAUSE 40000
 5060 GO TO 60
 5100 CLS 
 5105 
 5110 PRINT "ENTER: "
 5120 PRINT TAB 5;"DATE (AS 6 DIGITS)","         (120582)"
 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. THUNDERSHOWER"
 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 GO TO 300

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

People

No people associated with this content.

Scroll to Top