Egghead.page Logo

How to List Directory Contents in Commodore 128 BASIC

This article explains the specific command used to view disk directory contents within Commodore 128 native BASIC mode. It covers the primary syntax, optional parameters for drive selection, and important distinctions regarding system compatibility to ensure users can successfully navigate their file systems without loading external utilities.

The Primary Directory Command

In the native Commodore 128 environment, which runs BASIC 7.0, there is a built-in command designed specifically for viewing the contents of a floppy disk. The command is DIRECTORY. For faster typing, users can abbreviate this command to DIR. Unlike the Commodore 64, which requires loading the directory as a program or using a machine language wedge, the C128 handles this operation directly through the BASIC interpreter.

Syntax and Usage

To execute the command, simply type the keyword and press the Return key. The system defaults to checking the primary disk drive, which is typically device number 8. The basic usage looks like this:

DIRECTORY

or

DIR

If you have multiple disk drives connected to your system, you can specify the device number by adding a comma and the unit number after the command. For example, to view the directory of a drive connected as device 9, you would type:

DIRECTORY,9

Understanding the Output

Once the command is executed, the BASIC interpreter communicates with the disk drive controller. The screen will display the disk header, including the disk name and the ID number. Below the header, a list of files appears along with their respective block sizes. This information allows users to verify file names before loading them and to check available free space on the media.

Mode Compatibility Considerations

It is crucial to note that the DIRECTORY command only functions when the Commodore 128 is operating in its native 128 mode. If the computer is switched to C64 mode for backward compatibility, this command will not be recognized, resulting in a ?SYNTAX ERROR. Users operating in C64 mode must rely on alternative methods, such as loading the directory into memory or using third-party fast loaders that provide directory viewing capabilities.

Conclusion

Utilizing the DIRECTORY command is the most efficient method for managing files on a Commodore 128. By understanding the correct syntax and ensuring the system is in the proper operating mode, users can quickly access disk information without disrupting their current BASIC program or workflow.