>I am new to the list. I have FutureBasic II that I use for my LC, LC II, >and Powerbook 180c. None of these, of course are power macs. I am a low >power programmer also, writing Hypercard stacks and little Basic programs >for stuff around my office. > >I cannot figure out how to write code that will allow me to launch a >program from within a FutureBasic program. I want to have a screen pop up >that allows me to launch one or more files or programs from a list. For >instance, let's say I have these files: > Monthly Newsletter template (file) > News items (hypercard stack) > Page fillers (hypercard stack) > Daily Bulletin template (file) > Calendar (program) >When I click on a button labeled "Bulletin" I want "Daily Bulletin >template" to open, along with "News items." When I click on a button >labeled "Newsletter," I want "Monthly Newsletter template,"News items," and >"Page fillers" to open. I can do this in Hypercard (and have) but it is not >as elegant an interface as I would like to make. I am working on a project >that would integrate many aspects of communications in my office into one >program. As it is now, I have a bunch of little programs, and this little >problem is holding me up. > >I also want to know how I would store the addreses of those files in the >program itself in the resource fork or data fork. In other words, after >running it for the first time, the program will ask where each file is with >a file menu picker window, and then remember that location. I know I could >set up a preference file, but prefer to cut down on that sort of clutter. > >I would appreciate a private answer to these questions. I have days and >days of digests backed up as it is. So, if you answer to the list (for some >other readers' sakes), I would appreciate a blind copy also sent to me. > The purpose of the list is public answers that help everybody, so I will do so here. There are three ways to sublaunch files. the method used in System 6 (no obsolete) used a small sublaunch parameter block. (Used in FBII's RUN command.) The method used in system 7 used a larger parameter block. (Used in some examples created by Ariel Publishing on the IB Compleat CD and in other places, I think.) the modern way (later versions of system 7 and beyond) is to use Apple Events to send a message to the application. This is what is used in FB^3. If you are going to do it in FBII, you have a lot of work ahead of you. If your systems are old and you are not ready to upgrade, the old RUN statement might serve you well, but it was designed (back in the old days) to launch apps, not open files. Alternatively, if you want to see the general method used, you can look at the following code. But remember that this was just ripped from a working program and the surrounding stuff will have to be filled in by you. '-------------------------------------------------------------- 'AEOpenFile 'DCB 10/29/96 '-------------------------------------------------------------- CLEAR LOCAL MODE _kFinderSig = _"FNDR" 'Constants _kAEFinderEvents = _"FNDR" _kSystemType = _"MACS" _kAEOpenSelection = _"sope" _kKeySelection = _"fsel" _kTypeProcessSerialNumber = _"psn " _kTypeAlias = _"alis" _kKeyDirectObject = _"----" '_kAutoGenerateReturnID = -1 '_kAnyTransactionID = 0 '_kAEAlwaysInteract = &30 '_kAECanSwitchLayer = &40 '_kAENormalPriority = 0 '_kAEDefaultTimeout = -1 DIM fileSpec;0,vRefNum%,parID&,63 filename$ 'FSSpec for incoming file DIM myProcess;8 'Process SN of the Finder DIM appleEvent;0,dType0&,dHandle0& 'AE Record for the AppleEvent DIM returnDesc;0,dType1&,dHandle1& 'AE Desc returned by AESend proc DIM fileList;0,dType2&,dHandle2& 'AE Desc for file list DIM psnDesc;0,dType3&,dHandle3& 'AE Desc for PSN description record DIM parAliasDesc;0,dType4&,dHandle4& 'AE Desc for parent dir alias description record DIM fileAliasDesc;0,dType5&,dHandle5& 'AE Desc for file alias description record DIM err 'OSErr DIM fromFile 'set to nil for NewAlias proc DIM fileAlias&,parAlias& 'Alias stuff DIM fSpecAddr& LOCAL FN cAEMgr_OpenFile(pBlk&) fSpecAddr& = FN getPBlkVar(pBlk&) 'Get PSN of Finder LONG IF FN FindAProcess(_kFinderSig,_kSystemType,myProcess) = _noErr 'Create target addr LONG IF FN AECreateDesc(_kTypeProcessSerialNumber,myProcess,8,psnDesc) = _noErr 'Create empty AE LONG IF FN AECreateAppleEvent(_kAEFinderEvents,_kAEOpenSelection,psnDesc,_kAutoGe nerateReturnID,_kAnyTransactionID,appleEvent) = _noErr 'Make alias for file and parent directory fromFile = 0 err = FN NEWALIAS(fromFile,fSpecAddr&.nil%,fileAlias&) filename$ = "" LONG IF FN NEWALIAS(fromFile,fSpecAddr&.nil%,parAlias&) = _noErr 'Create file list LONG IF FN AECreateList(0,0,_false,fileList) = _noErr 'Create and load folder descriptor err = FN HLOCK(parAlias&) err = FN AECreateDesc(_kTypeAlias,=[parAlias&],FN GETHANDLESIZE(parAlias&),parAliasDesc) DEF DISPOSEH(parAlias&) LONG IF FN AEPutParamDesc(appleEvent,_kKeyDirectObject,parAliasDesc) = _noErr 'Create and load file descriptor err = FN HLOCK(fileAlias&) err = FN AECreateDesc(_kTypeAlias,=[fileAlias&],FN GETHANDLESIZE(fileAlias&),fileAliasDesc) DEF DISPOSEH(fileAlias&) LONG IF FN AEPutDesc(fileList,0,fileAliasDesc) = _noErr 'Load filelist into AE LONG IF FN AEPutParamDesc(appleEvent,_kKeySelection,fileList) = _noErr 'Send the Apple Event err = FN AESend(appleEvent,returnDesc,_kAENoReply_kAEAlwaysInteract_kAECanSwitc hLayer,_kAENormalPriority,_kAEDefaultTimeout,0,0) END IF END IF END IF END IF END IF END IF END IF END IF 'Kill all desc records IF dType0& THEN err = FN AEDISPOSEDESC(dType0&) IF dType1& THEN err = FN AEDISPOSEDESC(dType1&) IF dType2& THEN err = FN AEDISPOSEDESC(dType2&) IF dType3& THEN err = FN AEDISPOSEDESC(dType3&) IF dType4& THEN err = FN AEDISPOSEDESC(dType4&) IF dType5& THEN err = FN AEDISPOSEDESC(dType5&) END FN = err Best, -STAZ ~)~ 800.348.2623 Orders http://www.stazsoftware.com 228.255.7086 FAX mailto:staz@...