Legacy Documentclose button

Important: This document is part of the Legacy section of the ADC Reference Library. This information should not be used for new development.

Current information on this Reference Library topic can be found here:

Version: 1.0

Posted: 2003-01-14

Build Requirements: N/A

Runtime Requirements: Carbon

View Source Code:

Download Sample (“INIT_-_CDEV.zip”, 25.4K)
Download Sample (“INIT_-_CDEV.dmg”, 82.7K)



Description

INIT - CDEV is a sample that shows how a CDEV can communicate with an INIT. It is a System 7.0 sample, as it uses the PPCToolbox. It also uses the FindFolder routine to show how to read and write a preferences file, and the stand-alone globals techniques described in Technote #256. This sample demonstrates the following: * How to write an INIT that can stay resident. * How to write a Control Panel Device with extended error reporting * How to patch a trap * How to use the FindFolder routine for managing preferences * How to do quick and dirty PPCToolbox communications * How to use global variables in standalone code The INIT is just a simple "do nothing" INIT. It patches into SystemTask so that it can beep a certain number of times at regular intervals. At startup time, it reads a preferences file to find out how many times it should beep, and how often. If there isn't a preferences file, or we are running under 6.0.x and don't have the luxery of the FindFolder routine, we use the hard-wired setting of beeping 3 times every minute. However, the INIT doesn't really do anything 7.0-ish, so it still installs at startup even if you are running under 6.0.x. It just won't communicate with the CDEV. The CDEV can be used to change these settings. This CDEV runs under 7.0 only; it won't show up under 6.0.x. Also, it checks to see if the INIT was installed at startup time. If not, then it puts up an alert saying that it won't run unless the INIT is installed. There's no real good reason for doing this (i.e., you should be able to change the preferences file for the next time you reboot). But it shows how you can do your own error reporting in a CDEV. The CDEV is based on the EditText CDEV sample. It's been modified slightly to communicate with the INIT. When it's brought up, you are presented with two edit text boxes. The first lets you set the number of times you beep. The second lets you set the interval in seconds. Nothing happens until you close the CDEV. When you do that, the CDEV uses the PPCToolbox to ask the INIT for a pointer to a public variables space. Once it has that pointer, it moves the new values into that space. The INIT then makes its decisions based on the new settings.

Document Revision History

Date Notes
2003-01-14First Version

Did this document help you?
Yes: Tell us what works for you.
It’s good, but: Report typos, inaccuracies, and so forth.
It wasn’t helpful: Tell us what would have helped.