Time / Distance

This file is part of Timex Sinclair Public Domain Library Tape 1001 . Download the collection to get this file.
Date: 198x
Type: Program
Platform(s): TS 1000
Tags: Home

This program calculates the time required for a trip given a fixed distance and rate (speed). It divides a hardcoded distance of 250 miles by a rate of 65 (miles per hour) and prints the result in hours. The values for distance and rate are set as constants in lines 20 and 30, and the REM comments instruct the user to modify those lines directly when different values are needed. Lines 65–80 appear to be utility lines for saving and listing the program, placed after the STOP statement so they do not execute during normal program flow.


Program Analysis

Program Structure

The program is straightforward and linear. Execution begins at line 5 (a REM) and flows through to line 60 where a STOP halts execution. Lines 65–80 are utility lines that are never reached during a normal run.

  1. Lines 5–13: REM documentation and output header
  2. Lines 20–30: Constant assignment — D=250 (distance), R=65 (rate/speed)
  3. Line 40: Core calculation — T=D/R
  4. Line 50: Output of result
  5. Line 60: STOP — normal program termination
  6. Lines 65–80: Post-STOP utility lines (CLEAR, SAVE, LIST)

Variables

VariablePurposeValue
DDistance250
RRate (speed)65
TTime (result)D/R ≈ 3.84615…

Key BASIC Idioms and Notable Techniques

The program uses a purely hardcoded approach to input: the REM at line 11 explicitly tells the user to modify D and R in lines 20 and 30 directly, rather than using INPUT statements. This was a common technique in early hobbyist programs to keep code minimal and avoid input-handling overhead.

The result T is printed with surrounding spaces in the PRINT statement on line 50 (" ";T;" HOURS.") to visually separate the numeric value from the surrounding label text.

Post-STOP Utility Lines

Lines 65–80 are placed deliberately after STOP and are never executed during a normal run. They represent a developer workflow pattern: CLEAR at line 65 would reset variables, SAVE at line 70 saves the program, and LIST at line 80 would display the listing — useful commands to have accessible by editing the STOP line or jumping to them manually via GO TO.

Bugs and Anomalies

  • There is no INPUT prompt, so each new calculation requires the user to manually edit lines 20 and 30 — functional but not user-friendly.
  • No units are enforced or labelled for distance or rate; the output says “HOURS” but the correctness depends entirely on the user supplying consistent units.
  • Line 65 (CLEAR) follows STOP immediately in line numbering but would reset all variables if reached, which could be confusing if a user attempts to resume execution after a STOP.

Content

Appears On

Assembled by Tim Ward from many sources. Contains programs 10001 – 10050.

Related Products

Related Articles

Related Content

Image Gallery

Time / Distance

Source Code

   5 REM TIME/DISTANCE CALCULATION
  10 REM KNOW DISTANCE/RATE
  11 REM DISTANCE/RATE MOD AS REQURED
  12 PRINT "TIME REQUIRED FOR TRIP WHEN DISTANCE/TIME KNOWN"
  13 PRINT 
  20 LET D=250
  30 LET R=65
  40 LET T=D/R
  50 PRINT "THE TIME REQUIRED IS  ";T;"  HOURS."
  60 STOP 
  65 CLEAR 
  70 SAVE "1002%1"
  80 LIST 

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

People

No people associated with this content.

Scroll to Top