--- title: "Measurement Conversion" id: 57572 type: "computer_media" slug: "measurement-conversion" url: "http://localhost/computer_media/measurement-conversion/" markdown_url: "http://localhost/computer_media/measurement-conversion.md" published_at: "2024-10-05T22:13:47+00:00" modified_at: "2026-04-03T07:58:21+00:00" author: "David Anderson" featured_image: url: "http://localhost/wp-content/uploads/2024/10/measurement-conversion.png" excerpt: "A 21-unit measurement converter spanning length, volume, and weight that uses a computed GOTO to jump directly to whichever conversion routine you need." category: - name: "Archived Media" slug: "archived-media" taxonomy: "category" url: "http://localhost/category/archived-media/" post_tag: - name: "Downloadable" slug: "downloadable" taxonomy: "post_tag" url: "http://localhost/tag/downloadable/" - name: "TS 1000" slug: "ts1000" taxonomy: "post_tag" url: "http://localhost/tag/ts1000/" model: - name: "Timex/Sinclair 1000" slug: "ts-1000" taxonomy: "model" url: "http://localhost/model/ts-1000/" genre: - name: "Home" slug: "home" taxonomy: "genre" url: "http://localhost/type/home/" - name: "Mathematics" slug: "mathematics" taxonomy: "genre" url: "http://localhost/type/mathematics/" media_contents: - id: 56721 title: "Synchro-Sette April 1983" type: "computer_media" url: "http://localhost/computer_media/synchro-sette-april-1983/" media_type: "Program" mediadate: "April 1983" images: - url: "http://localhost/wp-content/uploads/2024/10/measurement-conversion.png" media_type_tags: "Home, Mathematics" --- # Measurement Conversion This program provides a comprehensive measurement conversion reference across three categories: length (inches through kilometers), volume (teaspoons through liters, using US customary units), and weight (ounces through kilograms). The menu screen displays all 21 unit types alongside a decorative right-hand border built from block graphics printed character by character using AT positioning. Navigation uses a computed GOTO at line 90 — `GOTO A*100` — which jumps directly to the handler routine for the selected unit, with each handler residing at a line number that is a multiple of 100. After displaying results, the program accepts any input via `INPUT A$` as a keypress-to-continue mechanism before restarting with `RUN`. *** ## Program Analysis ### Program Structure The program is organized into a menu section followed by 21 self-contained conversion blocks, each anchored at a line number that is a multiple of 100 (100 through 2100). After displaying the menu and accepting a choice at line 70–90, the computed `GOTO A*100` dispatches execution directly to the appropriate block. Each block follows a uniform four-step pattern: 1. Prompt for the input quantity (`PRINT`) 2. Accept the value (`INPUT A`) 3. Echo the value and print all conversions in a single `PRINT` statement 4. Wait for any key via `INPUT A$`, then restart with `RUN` ### Menu Rendering Lines 30–60 construct the menu display. The `FOR N=1 TO 22` loop at line 30 prints a decorative right-hand border column using block graphics (`\:` and `\ :`, rendering as ▌ and ▐), one character from the string `A$="MEASUREMENT CONVERSION"` per row, positioned at column 29 with `AT N-1,29`. Line 60 then prints all unit names and their associated numbers in a single large `PRINT` statement using the comma column-tab separator, filling in the left portion of the screen from `AT 0,0`. ### Computed GOTO Dispatch Line 90 uses `GOTO A*100` to jump to the selected handler. This is a clean O(1) dispatch mechanism that avoids a chain of `IF` statements. The valid input range is enforced at line 80 with `IF A<1 OR A>21 THEN GOTO 70`, though the computed target for A=21 is line 2100, which exists, so all values in range are handled correctly. ### Conversion Data The three conversion categories and their units are: | Category | Units covered | Menu numbers | | --- | --- | --- | | Length | Inches, Feet, Yards, Miles, Millimeters, Centimeters, Meters, Kilometers | 1–8 | | Volume (US customary) | Teaspoons, Tablespoons, Cups, Pints, Quarts, Gallons, Milliliters, Liters | 9–16 | | Weight | Ounces, Pounds, Tons (short), Grams, Kilograms | 17–21 | Volume conversions use US customary measures (e.g., 1 teaspoon = 4.9288665 mL, 1 gallon = 3785.3692 mL). The “ton” in the weight section is the US short ton (2000 pounds / 32000 ounces), not the metric tonne. ### Notable Techniques - **Computed GOTO:**`GOTO A*100` at line 90 replaces what would otherwise be 21 conditional branches, exploiting the regular line-number spacing. - **Single-statement output:** Each conversion block outputs all results in one `PRINT` statement using comma column separators to align values and labels in pairs across the screen. - **INPUT as keypress wait:**`INPUT A$` (lines 140, 240, etc.) is used as a “press any key” pause before `RUN` restarts the program; the user must type something and press Enter. - **RUN as restart:** Using `RUN` instead of `GOTO 20` clears all variables and restores a clean state, avoiding accumulation of any residual data across sessions. - **Block graphic border:** The right-hand column border uses the character-by-character loop (lines 30–50) to display individual letters of “MEASUREMENT CONVERSION” framed by block graphic characters, creating a decorative sidebar. ## Source Code ``` 10 LET A$="MEASUREMENT CONVERSION" 20 CLS 30 FOR N=1 TO 22 40 PRINT AT N-1,29;": ";A$(N);" :" 50 NEXT N 60 PRINT AT 0,0;"INCHES","- 1","FEET","- 2","YARDS","- 3","MILES","- 4","MILLIMETERS","- 5","CENTIMETERS","- 6","METERS","- 7","KILOMETERS","- 8","TSP","- 9","TBS","-10","CUPS","-11","PINTS","-12","QUARTS","-13","GALLONS","-14","MILLILITERS","-15","LITERS","-16","OUNCES","-17","POUNDS","-18","TONS","-19","GRAMS","-20","KILOGRAMS","-21" 70 INPUT A 80 IF A<1 OR A>21 THEN GOTO 70 85 CLS 90 GOTO A*100 100 PRINT ,,"HOW MANY INCHES? "; 110 INPUT A 120 PRINT A 130 PRINT ,,"= ",,,,A/12," FT",A/36," YDS",A/63360," MILES",A*25.4," MM",A*2.54," CM",A*.0254," MTRS",A*.0000254," KM" 140 INPUT A$ 150 RUN 200 PRINT ,,"HOW MANY FEET? "; 210 INPUT A 220 PRINT A 230 PRINT ,,"=",,,,A*12,"IN",A/3,"YDS",A/5280,"MILES",A*304.8,"MM",A*30.48,"CM",A*.3048,"MTRS",A*.0003048,"KM" 240 INPUT A$ 250 RUN 300 PRINT ,,"HOW MANY YARDS? "; 310 INPUT A 320 PRINT A 330 PRINT ,,"=",,,,A*36,"IN",A*3,"FT",A/1760,"MILES",A*914.4,"MM",A*91.44,"CM",A*.9144,"MTRS",A*.0009144,"KM" 340 INPUT A$ 350 RUN 400 PRINT ,,"HOW MANY MILES? "; 410 INPUT A 420 PRINT A 430 PRINT ,,"=",,,,A*63360,"IN",A*5280,"FT",A*1760,"YARDS",A*1609344,"MM",A*160934.4,"CM",A*1609.344,"MTRS",A*1.609344,"KM" 440 INPUT A$ 450 RUN 500 PRINT ,,"HOW MANY MILLIMETERS? "; 510 INPUT A 520 PRINT A 530 PRINT ,,"=",,,,A/25.4,"IN",A/304.8,"FT",A/914.4,"YARDS",A/1609344,"MILES",A*.1,"CM",A*.001,"MTRS",A*.000001,"KM" 540 INPUT A$ 550 RUN 600 PRINT ,,"HOW MANY CENTIMETERS? "; 610 INPUT A 620 PRINT A 630 PRINT ,,"=",,,,A/2.54,"IN",A/30.48,"FT",A/91.44,"YARDS",A/160934.4,"MILES",A*10,"MM",A*.01,"MTRS",A*.00001,"KM" 640 INPUT A$ 650 RUN 700 PRINT ,,"HOW MANY METERS? "; 710 INPUT A 720 PRINT A 730 PRINT ,,"=",,,,A/.0254,"IN",A/.3048,"FT",A/.9144,"YARDS",A/1609.344,"MILES",A*1000,"MM",A*100,"CM",A*.001,"KM" 740 INPUT A$ 750 RUN 800 PRINT ,,"HOW MANY KILOMETERS? " 810 INPUT A 820 PRINT A 830 PRINT ,,"=",,,,A/.0000254,"IN",A/.0003048,"FT",A/.0009144,"YARDS",A/1.609344,"MILES",A*1000000,"MM",A*100000,"CM",A*1000,"METERS" 840 INPUT A$ 850 RUN 900 PRINT ,,"HOW MANY TEASPOONS? "; 910 INPUT A 920 PRINT A 930 PRINT ,,"=",,,,A/3,"TABLESPOONS",A/48,"CUPS",A/96,"PINTS",A/192,"QUARTS",A/768,"GALLONS",4.9288665*A,"MILLILITERS",.0049288665*A,"LITERS" 940 INPUT A$ 950 RUN 1000 PRINT ,,"HOW MANY TABLESPOONS? "; 1010 INPUT A 1020 PRINT A 1030 PRINT ,,"=",,,,A*3,"TEASPOONS",A/16,"CUPS",A/32,"PINTS",A/64,"QUARTS",A/256,"GALLONS",14.786598*A,"MILLILITERS",.014786598*A,"LITERS" 1040 INPUT A$ 1050 RUN 1100 PRINT ,,"HOW MANY CUPS? "; 1110 INPUT A 1120 PRINT A 1130 PRINT ,,"=",,,,A*48,"TEASPOONS",A*16,"TABLESPOONS",A/2,"PINTS",A/4,"QUARTS",A/16,"GALLONS",236.58557*A,"MILLILITERS",.23658557*A,"LITERS" 1140 INPUT A$ 1150 RUN 1200 PRINT ,,"HOW MANY PINTS? "; 1210 INPUT A 1220 PRINT A 1230 PRINT ,,"=",,,,A*96,"TEASPOONS",A*32,"TABLESPOONS",A*2,"CUPS",A/2,"QUARTS",A/8,"GALLONS",473.17115*A,"MILLILITERS",.47317115*A,"LITERS" 1240 INPUT A$ 1250 RUN 1300 PRINT ,,"HOW MANY QUARTS? "; 1310 INPUT A 1320 PRINT A 1330 PRINT ,,"=",,,,A*192,"TEASPOONS",A*64,"TABLESPOONS",A*4,"CUPS",A*2,"PINTS",A/4,"GALLONS",946.3423*A,"MILLILITERS",.9463423*A,"LITERS" 1340 INPUT A$ 1350 RUN 1400 PRINT ,,"HOW MANY GALLONS? "; 1410 INPUT A 1420 PRINT A 1430 PRINT ,,"=",,,,A*768,"TEASPOONS",A*256,"TABLESPOONS",A*16,"CUPS",A*8,"PINTS",A*4,"QUARTS",3785.3692*A,"MILLILITERS",3.7853692*A,"LITERS" 1440 INPUT A$ 1450 RUN 1500 PRINT ,,"HOW MANY MILLILITERS? "; 1510 INPUT A 1520 PRINT A 1530 PRINT ,,"=",,,,A/4.9288665,"TEASPOONS",A/14.786599,"TABLESPOONS",A/236.58558,"CUPS",A/473.17116,"PINTS",A/946.3423,"QUARTS",A/3785.369,"GALLONS",A/1000,"LITERS" 1540 INPUT A$ 1550 RUN 1600 PRINT ,,"HOW MANY LITERS? "; 1610 INPUT A 1620 PRINT A 1630 PRINT ,,"=",,,,A/.0049288665,"TEASPOONS",A/.014786599,"TABLESPOONS",A/.23658558,"CUPS",A/.47317116,"PINTS",A/.9463423,"QUARTS",A/3.785369,"GALLONS",A*1000,"MILLILITERS" 1640 INPUT A$ 1650 RUN 1700 PRINT ,,"HOW MANY OUNCES? "; 1710 INPUT A 1720 PRINT A 1730 PRINT ,,"=",,,,A/16,"POUNDS",A/32000,"TONS",A*28.35,"GRAMS",A*.02835,"KILOGRAMS" 1740 INPUT A$ 1750 RUN 1800 PRINT ,,"HOW MANY POUNDS? "; 1810 INPUT A 1820 PRINT A 1830 PRINT ,,"=",,,,A*16,"OUNCES",A/2000,"TONS",A*453.6,"GRAMS",A*.4536,"KILOGRAMS" 1840 INPUT A$ 1850 RUN 1900 PRINT ,,"HOW MANY TONS? "; 1910 INPUT A 1920 PRINT A 1930 PRINT ,,"=",,,,A*32000,"OUNCES",A*2000,"POUNDS",A*907200,"GRAMS",A*907.2,"KILOGRAMS" 1940 INPUT A$ 1950 RUN 2000 PRINT ,,"HOW MANY GRAMS? "; 2010 INPUT A 2020 PRINT A 2030 PRINT ,,"=",,,,A/28.35,"OUNCES",A/453.6,"POUNDS",A/907200,"TONS",A/1000,"KILOGRAMS" 2040 INPUT A$ 2050 RUN 2100 PRINT ,,"HOW MANY KILOGRAMS? "; 2110 INPUT A 2120 PRINT A 2130 PRINT ,,"=",,,,A/.02835,"OUNCES",A/.453597,"POUNDS",A/907.200,"TONS",A*1000,"GRAMS" 2140 INPUT A$ 2150 RUN 9998 SAVE "MEASUREMENT CONVERSIO%N" 9999 RUN ```