[comp.sys.mac.programmer] FKEY trouble

c90davby@odalix.ida.liu.se (David Byers) (03/11/91)

I am working on an FKEY that will need to store four byte of data
between each invocation. Without that storage, it simply won't work.

The question is, how do i do it? The storage must be global,
independent of which application is in the foreground under
multifinder, and should stay around even if the user launches or exits
from an application.

Thanks for any help I can get.
--
 _____________________________________  ____________________________________
| David Byers                         ||SnailMail:     David Byers          |
| 				      ||               Ryds Alle 9:204      |
| c90davby@odalix.ida.liu.se          ||               S-58251 Linkoping    |
| byers@nanny.lysator.liu.se          ||               SWEDEN               |
`-------------------------------------'`------------------------------------'

Lawson.English@p88.f15.n300.z1.fidonet.org (Lawson English) (03/14/91)

David Byers writes in a message to All

DB> I am working on an FKEY that will need to store four byte of 
DB> data between each invocation. Without that storage, it simply 
To: c90davby@odalix.ida.liu.se


DB> won't work. 
DB> The question is, how do i do it? The storage must be global, 
DB> independent of which application is in the foreground under multifinder,

DB> and should stay around even if the user launches or exits from 
DB> an application. 
DB> Thanks for any help I can get

I have the same problem for an FKEY and while I haven't tried it yet, I think
the answer is to create a resource for the System (or your own file) called
"mLng" or somesuch. If it exists, then use it as a scratch pad, if it doesn't
exist, then create it. Use ID 1000 or somesuch and you should be set... (I hope)
Let me know if this works or if someone else comes up with a better way, as
I need to use this too. (ever want an interactive profiler that can "zoom in"
on the most used memory locations and display a graph from a DA while your program
is running?).


Lawson
 

--  
Uucp: ...{gatech,ames,rutgers}!ncar!asuvax!stjhmc!300!15.88!Lawson.English
Internet: Lawson.English@p88.f15.n300.z1.fidonet.org

gurgle@well.sf.ca.us (Pete Gontier) (03/20/91)

In article <5091.27E39C99@stjhmc.fidonet.org> Lawson.English@p88.f15.n300.z1.fidonet.org (Lawson English) writes:
>David Byers writes in a message to All
>DB> I am working on an FKEY that will need to store four byte of 
>DB> data between each invocation. Without that storage, it simply won't work. 
>DB> The question is, how do i do it? The storage must be global, 
>DB> independent of which application is in the foreground under multifinder,
>DB> and should stay around even if the user launches or exits from 
>DB> an application. 

>I have the same problem for an FKEY and while I haven't tried it yet, I think
>the answer is to create a resource for the System (or your own file) called
>"mLng" or somesuch. If it exists, then use it as a scratch pad, if it doesn't
>exist, then create it. Use ID 1000 or somesuch and you should be set... (I hope)

Ack! Talk about overkill!
 
Try a simple data-fork file in the System Folder. Or, better, in the
Preferences folder (System 7).
 
If that makes you ill, get a handle to yourself, set your globals, and call
ChangedResource on yourself. (UpdateResFile might be necessary as well,
but probably WriteResource is as far as you will have to go.)

But PLEASE don't go adding resources to the System file! Hideous no-no!
-- 
 Pete Gontier, gurgle@well.sf.ca.us
 Software Imagineer, Kiwi Software, Inc.