Startsidan  ▸  Texter  ▸  Teknikblogg

Anders Hesselbom

Programmerare, skeptiker, sekulärhumanist, antirasist.
Författare till bok om C64 och senbliven lantis.
Röstar pirat.

Sequential data on 5.25 inch floppies

2012-01-09

If you have an actual 1571 disk drive for your Commodore 128, insert a blank disk, format it using the HEADER command. Something like this:

HEADER "MY DISK", I44, D0

(Formatting a disk takes a while.)

If you are running a virtual Commodore 128 in VICE, click File, Attach disk image, Drive 8. Create a d64 image file and attach that image. To create the file, enter a desired filename, like test.d64, provide a name, click Create Image, then click Attach.

(The commands I use are available Commodore Basic 4.0 on Commodore PET, but I run Commodore Basic 7 on a C128.)

Your disk is now inserted and completely empty. You can check the content using the DIRECTORY command.

As a Commodore user, you know that you sometimes have to refer to your disk drive using its drive number (the first disk drive is 0) and sometimes you have to use the device number (the first disk drive is 8). The OPEN command operates on any device, therefore a device number is required in this case. The first parameter is the logical file number (just a number that identifies the file), the second is the device number (8). The third argument is a channel number – enter 2. Then, in one single string argument, you type in the file name, the file type and the file mode. I want to create a file called TEST.DAT as a sequential file and I want to write to it, so I my string holds “TEST.DAT,SEQ,WRITE”.

10 OPEN 1, 8, 2, "TEST.DAT,SEQ,WRITE"

To fill your file with data, use the PRINT# command. Anything goes here. This will print one string, one integer, and then yet another string. You provide your logical file number so that PRINT# knows what file you are targeting.

20 PRINT#1, "ONE STRING"
30 PRINT#1, 5
40 PRINT#1, "ANOTHER STRING"

If you like, more data can be added in one line.
When you are done writing, close the file using the CLOSE command. Again, provide your logical file number.

50 CLOSE 1

After running this program, you should have a small sequential file called TEST.DAT on your disk. If any disk error occurred, the lamp on your drive is flashing now – it shouldn’t do that.

Continued here.

Categories: Geeky

Tags: C128

Leave a Reply

Your email address will not be published. Required fields are marked *



En kopp kaffe!

Bjud mig på en kopp kaffe (20:-) som tack för bra innehåll!

Bjud på en kopp kaffe!

Om...

Kontaktuppgifter, med mera, finns här.

Följ mig

Twitter Instagram
GitHub RSS

Public Service

Folkbildning om public service.

Hem   |   linktr.ee/hesselbom   |   winsoft.se   |   80tal.se   |   Filmtips