INPUT#: Your File Data Gatherer

INPUT#: Your File Data Gatherer

Need to slurp up data from files in one big gulp? Tired of reading character by character with GET#? Look no further than the INPUT# command! This convenient tool lets you read an entire line of text from a file or device in a single go, making data input a breeze!

Syntax

INPUT# <file number>, <variable list>

Where: - <file number>: The logical file number (1-255) assigned to the file or device when you opened it using OPEN. - <variable list>: A comma-separated list of variables (both numeric and string) where the data will be stored. Each variable will receive the next item of data from the line, separated by commas.

Applications

The INPUT# command is perfect for:

  • Reading structured data: Easily read data organized into rows and columns, like comma-separated values (CSV) files or simple databases.
  • Processing text files: Quickly extract lines of text for analysis, formatting, or other manipulations.
  • Communicating with devices: Receive data packets from modems, printers, or other external devices.

Code Examples

1. Reading from a CSV File:

10 OPEN 1,8,8,"data.csv",S,R
20 INPUT#1, N$, A, S$
30 PRINT N$, A, S$  :rem Output: John, 35, New York
40 CLOSE 1

This example reads a line from a CSV file containing a name, age, and city, and then prints the values to the screen.

2. Processing a Text File:

10 OPEN 1,8,8,"story.txt",S,R
20 INPUT#1, L$   :rem Read a line of text
30 IF L$<>"" THEN PRINT L$
40 GOTO 20      :rem Read the next line

This snippet reads and prints each line of a text file until the end of the file is reached.

INPUT# in the Wild: The Commodore 64 Data Analyst

Imagine you're analyzing survey results stored in a CSV file on your Commodore 64. With INPUT#, you can easily read each respondent's data into variables for further analysis and visualization.

Don't nibble at your data – take a big bite with INPUT#! This powerful command streamlines file and device input, making it a valuable tool in your Commodore 64 programming arsenal. Whether you're parsing data, reading text, or communicating with peripherals, INPUT# is your trusted companion. So go forth and let the data flow!


Privacy Policy

Let's be honest, we collect some data. But we promise not to sell it, we'll mostly use it to improve our service. You can read the nitty-gritty details below, but be warned, it uses big words that lawyers like (we don't judge).

By using our service, you agree to this privacy policy. This disclaimer strikes a balance between lightheartedness and informing users that they should still read the full privacy policy if they choose.