Help with setRegistry?

Ken Ray kray at sonsothunder.com
Wed Jul 31 18:47:01 EDT 2002


Eric,

On the Mac, your app will get apple events (specifically the "odoc" event),
from which you can extract the file path (this is from Ben Rubenstein from
an old post last year - thanks, Ben!):

> To do this on the Mac, your stack needs to handle the
> "appleEvent" message.
>
> Put the following handler in your stack script:
>
>     on appleEvent eClass, eID, eSender
>        if eClass = "odoc" then
>           request appleEvent data
>           if the result = empty then
>              answer "OpenDoc AppleEvent!" & return \
>                 & "id =" && eID \
>                 & "sender =" && eSender \
>                 & "data =" && it
>           else
>              pass appleEvent
>           end if
>        else
>           pass appleEvent
>        end if
>     end appleEvent
>
> Build a standalone, and try it.  You should see that when you
> drag and drop
> a file, this handler fires, and the data for the apple event
> is the path of
> the file(s).
>
> The issue about which files you can drag-and-drop onto your app is
> determined by the resources in the app.  When the standalone
> is built, it is
> given the same resources as MetaCard itself - so it accepts
> stacks.   You
> need to change these resources to identify the kind of files
> your app should
> accept.  The resources in question are the file reference
> ('FREF'), icon
> list ('ICN#') and bundle ('BNDL') resources.  You should be
> able to get
> information about these on the apple site
> (developer.apple.com) (I'm on the
> road at the moment, with email access only - can't give you exact
> referencess.)  You'll need a resource editor - ResEdit or
> Resorceror.  Note
> that you can only filter by Mac type codes, not by file extensions.

Hope this helps,

Ken Ray
Sons of Thunder Software
Email: kray at sonsothunder.com
Web Site: http://www.sonsothunder.com/


----- Original Message -----
From: "Eric Rivers" <erivers at rpsystems.net>
To: <use-revolution at lists.runrev.com>
Sent: Wednesday, July 31, 2002 4:29 PM
Subject: Re: Help with setRegistry?


> Ken,
>
> > OK, now you have all the registry settings. The next thing to do is add
> some
> > code to your app. When you launch an MC/Rev app, any command line
> > information is sent to the application and is retrievable via
*environment
> > variables* numbered $0 on up. The $0 variable will always contain the
path
> > to the application you just launched, and the $1 will contain the first
> > command-line parameter passed ($2 will be the second, etc.).
> >
> > So some simple code for this is:
> >
> > on openStack
> >   put $0 into theAppPath
> >   put $1 into theDocToOpen
> >   answer "The doc to open is: " & theDocToOpen
> > end openStack
> >
> > (Note that you'll need to bundle in the answer dialog box to your
> standalone
> > or you'll never see the message. ;-)
> >
> > That's it! The next time you create a document with a ".tst" extension,
it
> > will take on the icon in the first position in the TestApp executable
(the
> > document icon), and if you double-click it, it will launch TestApp and
its
> > path will be passed to the standalone as $1.
> >
> > Hope this clears things up... (and yes, I'll post this to my site in the
> > MC/Revolution Tips area)
>
> This seems to work just fine on Win32 but MacOS (specifically OS X) isn't
> getting anything in the $1 variable.  The Win32 version is utilizing %1
when
> calling the application to pass the file path to the document in $1.  But
> trying to open the app on a Mac by launching a document never passes the
> file path to the app.
>
> The standalone is designed to either prompt for a stack file (a document)
to
> use when it opens or it uses the file path info of the stack that was
> launched.  On Win32, the process performs nicely but on Mac it never
> recognizes that a document was used to launch the standalone and prompts
the
> user to select a stack file, then proceeds normally.  In other words,
> 2X-clicking the stack launches the standalone but does not pass itself as
a
> parameter.
>
> Thanks in advance for any further help you can provide.
>
>
> Eric
>
> Eric Rivers
> RPSystems
> http://www.rpsystems.net
>
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> http://lists.runrev.com/mailman/listinfo/use-revolution
>




More information about the use-livecode mailing list