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.
- 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.
- Read 3. In decbfile this is DECB_ERR_NOT_FOUND. A successful build and a file-open failure can both be true.
- 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.
- 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.
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.