GET#: Your File and Device Manager
Want to read data from files or devices character by character? GET#
is your go-to command! This handy tool lets you fetch individual characters from a specified file or device, giving you granular control over input and the ability to process data as it arrives. Think of it as your communication conduit to the world beyond your keyboard!
Syntax
GET# <file number>, <string variable>
Where:
<file number>
: The logical file number (1-255) assigned to the file or device when you opened it usingOPEN
.<string variable>
: A string variable (ending in$
) that will store the captured character.
Applications
The GET#
command is your friend when:
- Reading from files: Process text files, configuration files, or data logs one character at a time.
- Communicating with devices: Receive input from modems, printers, or custom hardware interfaces.
- Creating interactive programs: Build applications that respond to real-time input from external sources.
Code Examples
1. Reading from a File:
10 OPEN 1,8,8,"myfile,S,R" :rem Open a sequential file for reading
20 GET#1, C$ :rem Read a character into C$
30 IF C$<>"" THEN PRINT C$; :rem Print the character if not end of file
40 GOTO 20 :rem Read the next character
This loop reads and prints the contents of a file character by character until the end of the file is reached.
2. Receiving Data from a Modem:
10 OPEN 1,1,1,"RS232:C1200" :rem Open a serial port for communication
20 GET#1, C$
30 IF C$<>"" THEN PRINT C$;
40 GOTO 20
This example waits for incoming characters from a modem connected to the RS-232 port and displays them on the screen.
GET# in the Wild: The Commodore 64 Teleprompter
Imagine you're giving a presentation and want to use your C64 to display your script. You could store the text in a file and use GET#
to read and display the characters one by one, creating your own personal teleprompter!
Don't be limited by the keyboard! With GET#
, you can unlock a world of data sources and external devices, creating programs that interact with the world around them. It's like having a universal translator for your Commodore 64, allowing it to communicate with all sorts of hardware and software. So go forth and explore the power of GET#
– the possibilities are endless!