Placing the handle in the system heap could work just fine. The only reason
that an application would die using this method is if you didnt save the
handles address. If the block of memory is relatively small I would stick
with the system heap.
In order to share a common block of data, both applications need to know
where the handle/pointer resides. The application that made the request
knows where the handle is but for another application to know where it
resides requires communication with the other program OR they have to share
information via a common file. Not many programs share a common file so to
communicate with another application you would have to use one of the
following
A custom gestalt
An init
Appleevents
Custom low level events
PPC communications (I'm not sure this manager still exists)
Of the above the only one that I would use is appleevents. In the past I've
used all above and with the exception of appleevents, they are all a pain in
the behind to use. Sending information between application isnt that hard.
I find the biggest probem is signaling the applications to stop accessing
the shared block. One program will dispose the block of memory and the
other may still be trying to access the block. Finding a way to communicate
the block is no longer accessible before the 'other' program tries to access
the block is the difficult part. This assumes both programs are not
synchronously synergistic. If they are synchronous then signaling is not a
problem.
A good example of using Appleevents is the appleevents.incl that comes on
the CD. It has pretty much everything needed unless you want to get into
some sophisticated appleevent communications.
W.
-----Original Message-----
From: lcs@... [mailto:lcs@...]
Sent: Friday, February 16, 2001 1:14 PM
To: futurebasic@...; lcs@...
Subject: [FB] Trading Handles
Hi all--
I would like to pass big chunks of data from one application of
mine to another of mine without going via a disk file.
I have used the "clipboard" in the distant past;
but, between sister applications, something simpler
faster and more robust should be possible. (I recall a lot of clip
capacity problems...)
My idea is to use handles in the system heap
via
H&=FN NEWHANDLE _sys(size&)
This works to the extent that the handle and its data are
accessible to both applications as soon as I pass the value of
H& by some adequate subterfuge (clipboard?).
A problem occurs if the sister who created the handle dies:- the
handle dies with her. It is possible to work around this by
BLOCKMOV'ing the data from one sister's handle to the other's.
(or use HANDTOHAND or HANDANDHAND) But
that is a huge waste of RAM and some waste of time.
Ideally I would like to, in effect, transfer ownership of the
handle, or maybe have all shared data handles belong to some
common custodian.
Since I want this to work for all Macs from the year dot,
I put a premium on elementary solutions.
Suggestions?
Best wishes,
Larry S
--
To unsubscribe, send ANY message to <futurebasic-unsubscribe@...>