[comp.sys.mac.programmer] CDEV question

ack@eleazar.dartmouth.edu (Andy J. Williams) (07/26/88)

[ Sorry, all my catchy line eater jokes were eaten by the line eater ]

We are writing a DA which, being quite large, will have an external file in
the System Folder (Much the same as Canvas(TM) DA has Canvas Helper).

There are some attributes of this program that we would like to have
controlled by a cdev. (Mainly, the behavoir of an INIT associated with the
DA which affects the environment outside the DA).

The question is:  If the DA is open, accessing this helper file which
contains the cdev resource, will the Control Panel be able to still load
the cdev if requested by the user?  Or, will the control panel choke saying
that the file is in use or locked or what have you?  If so, is there a way
around it?

Thanks in advance.  (eMail to me, if there is an interest I'll post a
summary to the net)

-Andy


Andy J. Williams '90   |Ack Systems: ack@eleazar.dartmouth.edu|   _   /|
Software Development   +--------------------------------------+   \`o_O' ACK!
Kiewit Computation Ctr |Hello. Set $NAME='Iinigo Montoya' You |     ( )  /
Dartmouth College      |kill -9 my process.  Prepare to vi.   |      U

spector@vx2.GBA.NYU.EDU (David HM Spector) (07/26/88)

I am note sure if the file permissions will help you any... but one  other
way to make sure that your cDev can access the file is to have the both the 
cdev and the da close their common file whenever they recieve and deactivate 
events and reopen it when they're brought to the front againt.  This is 
guarenteed to work because your da and the control panel cannot both be 
frontmost at the same time.....

Deactivate events are good times to save data files and configurations anyway..
you never know what some obnoxious application is going to do to you when 
you're not looking. :-)  The only problem is that you'll have to "suspend"
whatever you're doing when you get deactivated... unless you can come up with 
either a clever semaphore or perhaps just trying to re-open the file every 
now and then while you're not front most, and if you get a file locked error
then your cDev must be awake and accessing the file.

jsut a few Q&D ideas...hope that helps a little...

_David
-------------------------------------------------------------------------------
David HM Spector				New York University
Senior Systems Programmer			Graduate School of Business
Arpa: SPECTOR@GBA.NYU.EDU			Academic Computing Center
UUCP:...!{allegra,rocky,harvard}!cmcl2!spector	90 Trinity Place, Rm C-4
HamRadio: N2BCA      MCIMail: DSpector          New York, New York 10006
AppleLink: D1161     CompuServe: 71260,1410     (212) 285-6080
"What computer puts out work like this?"  "Hire us and we'll tell you."
XYZZYGLORP

wb1j+@andrew.cmu.edu (William M. Bumgarner) (08/03/88)

>> The question is:  If the DA is open, accessing this helper file which
>> contains the cdev resource, will the Control Panel be able to still load

no can do.  I just opened Pyro! with Resedit, and then opened the Control
Panel.  After clicking on the Pyro! ICON, CPanel returned 'CPanel cannot load
resource file'.  closing in Resedit reenabled Pyro!.

Usually, you would want the helper file in a complete different file from the
cdev anyway; that way, if someone needs to free up some space, they can chuck
the help file.

b.bum
wb1j+@andrew.cmu.edu

erics@eleazar.dartmouth.edu (Eric Schlegel) (08/03/88)

In article <0WxTlMy00V4U8C20UD@andrew.cmu.edu> wb1j+@andrew.cmu.edu (William M. Bumgarner) writes:
>>> The question is:  If the DA is open, accessing this helper file which
>>> contains the cdev resource, will the Control Panel be able to still load
>
>no can do.  I just opened Pyro! with Resedit, and then opened the Control
>Panel.  After clicking on the Pyro! ICON, CPanel returned 'CPanel cannot load
>resource file'.  closing in Resedit reenabled Pyro!.

But this probably doesn't work because both ResEdit and the Control Panel will
try to open Pyro for reading and writing, which will conflict. If you open
the DA helper file for reading only, the Control Panel will still be able to
open the file for both reading and writing and there shouldn't be any problems.


------
Eric Schlegel                 |  DISCLAIMER: I'm just a poor college student,
eric.schlegel@dartmouth.edu   |  which means I'm not responsible for what I
                              |  say and I can't pay you if you sue me anyway.

ack@eleazar.dartmouth.edu (Andy J. Williams) (08/04/88)

Way back when, I wrote:

 The question is:  If the DA is open, accessing this helper file which
contains the cdev resource, will the Control Panel be able to still load

wb1j+@andrew.cmu.edu (William M. Bumgarner) responded:

no can do.  I just opened Pyro! with Resedit, and then opened the Control
Panel.  After clicking on the Pyro! ICON, CPanel returned 'CPanel cannot load
resource file'.  closing in Resedit reenabled Pyro!.

And erics@eleazar.dartmouth.edu (Eric Schlegel) then responded:

>But this probably doesn't work because both ResEdit and the Control Panel will
>try to open Pyro for reading and writing, which will conflict. If you open
>the DA helper file for reading only, the Control Panel will still be able to
>open the file for both reading and writing and there shouldn't be any problems.

And now, I respond:

Well, for one, I have been informed that when you have a resource open it is
for read and write, not one or the other.  Don't quote me on this.

At any rate, my original question is moot.  We've decided to scrap the cdev
seeing as it is rather odd for a cdev to control another programs options
(in this case, controlling how a remote server alerts you to new mail.  the
mail DA itself will now handle these preferences)

Thanks for the help anyway...

Andy


Andy J. Williams '90   |Ack Systems: ack@eleazar.dartmouth.edu|   _   /|
Software Development   +--------------------------------------+   \`o_O' ACK!
Kiewit Computation Ctr |Hello. Set $NAME='Iinigo Montoya' You |     ( )  /
Dartmouth College      |kill -9 my process.  Prepare to vi.   |      U

mm5l+@andrew.cmu.edu (Matthew Mashyna) (02/10/90)

I took the example cdev that comes with MPW C and Think C. I tried
to change them so a field is edtable and is saved in a resource. I'm
getting really goofy results with STR's. I can save data resources with
no problems. If I edit the text and close the control panel the text is
fine. But when I select another device, the text gets mangled. What's
the deal ? What event happens when another device is selected ?

Any Ideas ?

Matt Mashyna
mml5@andrew.cmu.edu

6600pete@ucsbuxa.ucsb.edu (GurgleKat [Pete Gontier]) (02/10/90)

From article <EZoiyVK00iLOQARlxb@andrew.cmu.edu>, by mm5l+@andrew.cmu.edu (Matthew Mashyna):
> I took the example cdev that comes with MPW C and Think C. I tried
> to change them so a field is edtable and is saved in a resource.

There's an entire Tech Note on this. Sorry I can't remember what number
it is, but then again that's what the HyperCard stack is for.

------------------------------------------------------------------------------
Pete Gontier   | InterNet: 6600pete@ucsbuxa.ucsb.edu, BitNet: 6600pete@ucsbuxa
Editor, Macker | Online Macintosh Programming Journal; mail for subscription
Hire this kid  | Mac, DOS, C, Pascal, asm, excellent communication skills