Hello folks, As we discussed in another thread, it seems that I cannot display a form scanning the contents of a memory card on volume mounted notification. So, I have to set an alarm, in order to do it later. I also don't want to let start.prc execute before I've scanned the card - so I have to prevent its execution and to execute it myself when the alarm is triggered and I've finished scanning the card. Well, how do I do that?!
I've noticed that the Launcher copies start.prc to the main memory and runs it from there (of course) but only deletes it when the volume is unmounted. So, I'll have to listen to the volume unmounted event too. And let's not forget that start.prc might still be running when the volume is unmounted - so maybe I should wait until its database is no longer open before trying to delete it? So, I need two alarms - one to tell me to run start.prc and another to tell me to delete it. In order to run it, I need the volume reference on which it resides - i.e., the volume that was just mounted. OK, I suppose I can pass that in the "ref" field of the alarm. Question #1: Since I have to pass several things this way (code indicating what kind of alarm it is, volume reference, possibly other things), obviously "ref" must be a pointer to a structure. Let me guess - it can't be a global structure, right? So, I'll have to allocate this structure when setting the alarm and free it when the alarm triggers. Can I rely that the memory allocated for this structure will remain available between setting the alarm and its triggering? Or do I have to do stupid tricks like setting the owner of that memory to zero? Question #2: OK, so I'll copy start.prc to the main memory using VFSImportDatabaseFromFile. But how do I run it afterwards? With SysUIAppSwitch or with SysAppLaunch? The documentation suggests that SysUIAppSwitch is used when switching to another application from your normal (i.e., with user interface) application - because it posts appStopEven that your application is supposed to catch and quit. But I'll be launching start.prc from an alarm. I won't be in an event loop at this point. Does that mean that I should use SysAppLaunch? But I seem to remember having read somewhere that one shouldn't use SysAppLaunch with the sysAppLaunchCmdNormalLaunch launch code - is that correct or am I imagining things? Question #3: What should I pass as the cmdPBP argument? NULL? When the volume is unmounted, I should delete start.prc from the main memory. How do I do that? There are two problems. Question #4: For instance, the application might still be running. So, I guess if the deletion fails, I should set an alarm to try deleting it later. How much later? Should I try to delete it every second or so? Or maybe this problem wouldn't exist if I launch it with SysAppLaunch - because that one is supposed to return to the caller (which I though was not supposed to be done by "properly designed PalmOS applications")? Question #5: How do I *find* the start.prc in the main memory anyway? I probably cannot expect its LocalID at the time when I have copied it there to remain the same - what if meanwhile other databases have been created? OK, so I could remember its type (wouldn't that always be 'appl'?) and creatorID and then use DmGetNextDatabaseByTypeCreator to locate it. But what if another application with this creatorID already existed on the device before the memory card was inserted? How would I know which one to delete? Can I rely on the onlyLatestVers argument of for this purpose? Or should I remember other properties in addition to the type and creatorID (version? modification number? anything else?) and then use DmGetNextDatabaseByTypeCreator in a loop and call DmDatabaseInfo for everything it finds - until I find one for which all the remembered properties match? Questions, questions... Sigh... Would have been *so* much easier if PalmOS would let me simply scan the card when it is mounted... :-( Regards, Vesselin -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/
