/****************************************************************************** * * File: myGoToPedit.c * * * by Paul Nevai [2me@PaulComputing.com] on July 07, 2000 * *****************************************************************************/ #include /********************** ADD THESE TO YOUR HEADER FILES *********************/ #ifndef memo04DBName # define memo04DBName "MemoDB" #endif #ifndef memo32DBName # define memo32DBName "Memo32DB" #endif #ifndef memosDBName # define memosDBName "MemosDB-PMem" #endif #ifndef memoDBType # define memoDBType 'DATA' #endif #ifndef Memo04DBCreator # define Memo04DBCreator sysFileCMemo // = 'memo' #endif #ifndef Memo32DBCreator # define Memo32DBCreator 'pn32' #endif #ifndef MemosDBCreator # define MemosDBCreator 'PMem' #endif #ifndef pedit04Creator # define pedit04Creator 'pn10' #endif #ifndef pedit32Creator # define pedit32Creator 'pn32' #endif #ifndef peditProCreator # define peditProCreator 'pnPr' #endif #ifndef peditLightCreator # define peditLightCreator 'pnLi' #endif #ifndef noDbID # define noDbID 0 #endif /******************** EOF ADD THESE TO YOUR HEADER FILES *******************/ // local functions // static Boolean myVanDBSharedLoc (UInt32 theTypeID, UInt32 theCreatorID); extern Err myGoToPedit (UInt16 theRecIndex, UInt16 theCursorPosition, Int16 theSelectionSize, Int16 theWhichMemoDB, Int16 theWhichPedit); // EOF local functions // #pragma mark ---- // 01_20_2004: created myVanDBSharedLoc() - see myVanDBShared() static Boolean myVanDBSharedLoc (UInt32 theTypeID, UInt32 theCreatorID) { DmSearchStateType searchState; UInt16 cardNo; LocalID dbID; return ((Boolean) ( (DmGetNextDatabaseByTypeCreator (true, &searchState, theTypeID, theCreatorID, true, &cardNo, &dbID) == errNone) && (dbID != noDbID) )); } // EOF static Boolean myVanDBSharedLoc() /*********************************************************************** * * FUNCTION: myGoToPedit * * DESCRIPTION: This routine is an example how to go to a pedit memo from another application * * PARAMETERS: theRecIndex - index of the memo [first memo's index is 0] * N.B. Use theRecIndex = noRecordSelected [= 0xFFFF] to go to ListView * theCursorPosition - self-evident * theSelectionSize - self-evident * N.B. make sure that theCursorPosition + theSelectionSize <= StrLen (your memo) * theWhichMemoDB - if 32 then it opens a 32K pedit memo, otherwise a 4K pedit memo * theWhichPedit - if 32 then it opens pedit32, otherwise pedit or peditLight * N.B. By default, it opens peditPro if it is installed. * * * RETURNED: nothing * * REVISION HISTORY: * Name Date Description * ---- ---- ----------- * paul 07/06/2000 initial revision * paul 07/10/2000 fine tuning * paul 01/10/2002 fine tuning * paul 01/22/2004 compatibility with the 32K PIM "Memos" application * ***********************************************************************/ extern Err myGoToPedit (UInt16 theRecIndex, UInt16 theCursorPosition, Int16 theSelectionSize, Int16 theWhichMemoDB, Int16 theWhichPedit) { const Boolean has32KMemos = myVanDBSharedLoc (memoDBType, MemosDBCreator); const UInt32 memo04DBCreatorID = (UInt32) (has32KMemos ? MemosDBCreator : Memo04DBCreator); // // Err error = errNone; DmSearchStateType searchState; UInt16 cardNo; LocalID dbID; GoToParamsType * goToParamsP; UInt32 peditCreatorID; UInt32 memoDBCreatorID; // init vars dbID = noDbID; goToParamsP = NULL; memoDBCreatorID = ((theWhichMemoDB == 32) ? Memo32DBCreator : memo04DBCreatorID); // EOF init vars // find the vitals of the appropriate pedit if ((DmGetNextDatabaseByTypeCreator (true, &searchState, sysFileTApplication, peditProCreator, true, &cardNo, &dbID) == errNone) && (dbID != noDbID)) {peditCreatorID = peditProCreator;} else if (theWhichPedit != 32) { if ((DmGetNextDatabaseByTypeCreator (true, &searchState, sysFileTApplication, pedit04Creator, true, &cardNo, &dbID) == errNone) && (dbID != noDbID)) {peditCreatorID = pedit04Creator;} else if ((DmGetNextDatabaseByTypeCreator (true, &searchState, sysFileTApplication, peditLightCreator, true, &cardNo, &dbID) == errNone) && (dbID != noDbID)) {peditCreatorID = peditLightCreator;} } // EOF else if (...) else if ((DmGetNextDatabaseByTypeCreator (true, &searchState, sysFileTApplication, pedit32Creator, true, &cardNo, &dbID) == errNone) && (dbID != noDbID)) {peditCreatorID = pedit32Creator;} else {return (appErrorClass | 1);} // find the vitals of the appropriate MemoDB if ((DmGetNextDatabaseByTypeCreator (true, &searchState, memoDBType, memoDBCreatorID, true, &cardNo, &dbID) != errNone) || (dbID == noDbID)) {return (appErrorClass | 2);} if ( ((goToParamsP = MemPtrNew (sizeof (GoToParamsType))) == NULL) || (MemPtrSetOwner (goToParamsP, 0) != errNone) // we need to relinquish ownership to the OS || (MemSet (goToParamsP, sizeof (GoToParamsType), 0) != errNone) ) {return (appErrorClass | 3);} // DO NOT USE goToParamsP->searchStrLen - USE goToParamsP->matchCustom instead // goToParamsP->searchStrLen = theSelectionSize; // length of search string goToParamsP->dbCardNo = cardNo; // card number of the database goToParamsP->dbID = dbID; // LocalID of the database goToParamsP->recordNum = theRecIndex; // index of the record that contains a match goToParamsP->matchPos = theCursorPosition; // position in the record of the match // goToParamsP->matchFieldNum = 0; // field number in which the string was found goToParamsP->matchCustom = theSelectionSize; if ((DmGetNextDatabaseByTypeCreator (true, &searchState, sysFileTApplication, peditCreatorID, true, &cardNo, &dbID) == errNone) && (dbID != noDbID)) {return (SysUIAppSwitch (cardNo, dbID, sysAppLaunchCmdGoTo, (MemPtr) goToParamsP));} return (appErrorClass | 4); } // EOF Err void myGoToPedit() #pragma mark ----