← Manual LibraryVCC Plus 3.7.1 · Reading on the web

Try the exercises in VCC Plus. Example links download files here; open them in the app to work beside the emulator.

The complete book · PDF editionBook 6: Programming in C on the CoCo 3 — CMOC and Its APIs

198 pages · VCC Plus 3.7.1 · Keep a copy to read or print.

Download PDF
Contents

Chapter 7 of 9

Find the file that went missing

Suppose Hello Disk builds successfully, prints the heading for the words, and immediately skips to the result. Which end needs a repair: the Mac build, the image, or the program on the CoCo? Change one thing so you can answer that question from evidence.

Make a fault you can undo

Use a private five-word Hello Disk project in Debug. In src/disk.c, change only the filename in the open call from WORDS.DAT to WRONG.DAT. Save All and Build Disk. Leave the resource list alone. The tools have every file they need on the Mac, and WRONG.DAT is a perfectly valid C string. Expect a successful build.

Catch the returned value

Find the second if (status == DECB_OK) in showDiskWords, immediately below the call to decb_openSectorFile. In the shipped sample it is line 18. In the Source breakpoint picker at the bottom of the C workspace, select Line 18, then click the adjacent plus button to add the stop. If you stop on the call itself, the assignment you want to measure is still ahead of you. If you stop at the previous condition, you are measuring registration of drive zero.

  1. Choose Launch Disk so the guest uses the newly built image. At the source stop, select the showDiskWords frame. Open Variables, or enter status in Watches.
  2. Read 3. In decbfile this is DECB_ERR_NOT_FOUND. A successful build and a file-open failure can both be true.
  3. Select the main frame in the call stack. It can show where the disk operation was requested. Its own variable named status receives a return value only when showDiskWords finishes. Select the inner frame again to read the meaningful value at this stop.
  4. Continue. Expect DISK RESULT: 3, GENERATED WORD COUNT: 5, and no printed words. At OK, type DIR. The disk still lists WORDS DAT. Compare the spelling with the C string.
A private Hello Disk copy named MissingWords has stopped on line 18, immediately after the open of WRONG.DAT. In the showDiskWords frame, Variables reports status 3.
The same guest screen shows disk result 3 and count 5 above the DIR listing for HELLO BIN and WORDS DAT.

If the debugger says a source location is unavailable, check that you built the saved Debug sources and launched the matching artifact. The editor can remember a line while the executable and address behind that line change. Resolve a stop against the new build before interpreting its variables.

Repair one name

Restore WORDS.DAT in src/disk.c, save, build the disk and launch it. Use the same post-open source line. This time status is 0, the library's DECB_OK. Continue: the five words reappear. The count still says 5 because the word list was never edited. With the breakpoint selected, click the adjacent minus button to clear it.

You have distinguished three independent claims. The linker produced an executable. The directory contained a named file. The program found that file at run time. Each was worth checking in a different place.

For a program with no floppy dependency, try a graphics, input or sound experiment. To make a copy for a friend, go straight to the six-word disk.

Original VCC Plus manuals © 2026 Brian K. Holman. Third-party references retain their authors’ copyrights and licenses. Artwork notices. Edition 3.7.1; source and export identity. Printable edition: PDF source and export identity.

A closer look

Open original