14. A computer storage media for storing any of instructions and data for causing a digital data processing apparatus to operate in accord with the methods of any of claims 1 - 11.
APPENDIX I to
METHOD AND APPARATUS FOR PREDICTING AND IMPROVING PATIENT COMPLIANCE WITH MEDICAL TREATMENT
© ParetoScope, Inc. 1997
EnrichMap® Health Care and Personal Opinion Questionnaire © ParetoScope, Inc. 1997 Agree Do Not Agree Completely At All
1 2 4 5
I'm almost always satisfied with the medical treatment
I receive There are a lot of health care people that you can't trust Doctors sometimes seem to make decisions before I finish explaining my problems or asking all my questions I know people who do not exactly follow the doctor's advice and they seem to do just fine I never know what questions to ask when I go to the doctor with a problem I try to keep up with current medical information whether I have a problem or not I've read or heard about new health care treatments that my doctor did not know about
When I get sick or have a serious problem, I do my own research about the illness and treatments I feel I personally know enough about some medical problems and treatments that I feel comfortable giving advice about them
The costs I pay for health care are reasonable
There is so much information about what is healthy and what is not that it is impossible to make sense of it
I often seek advice from other people
I'm a patient person I don't like to make long term plans
The quality of many products has gone down
I feel comfortable using the newest technologies
I am very good about planning things in order to keep my appointments You really do not have much control over what happens to you in life like an illness, it's just a matter of fate or luck
I am pretty good about following healthy eating habits I wear seatbelts as a driver and as a passenger in a car or truck all the time
DS 1.3946304
APPENDIX II to
METHOD AND APPARATUS FOR PREDICTING AND IMPROVING PATIENT COMPLIANCE WITH MEDICAL TREATMENT
© 1997-8 Seth M. Powsner and ParetoScope, Inc. (as indicated)
//Routines are arranged alphabetically.
//Program execution begins when PilotMam is called by the Pilot Operating system.
//AppDBClose.c — Application Database Close; © 1997-8 Seth M Powsner
#╬╣nclude <P╬╣lot.h> #mclude "AppDBGlobals .h" #mclude "AppDBClose.h"
Err AppDBClose (void) t
Err error = 0; if (appDB)
//error |= Dr╬▒ResetRecordStates (appDB) ; // snould be safer but. error |= DmCloseDatabase (appDB) ; return error;
/♦Generic database close aαapteα from MemoPad.c per Code arπor Targettmg Palm OS v.1.2.1 pp.13 Modification nistory
980222 SMP cosmetic
970927 SMP initial coding
*/
/*EOF - - - - - - - - - - - - - - - - - - - - - -
//AppDBClose.h; © 1997-8 Seth M Powsner extern Err AppDBClose (void) ;
/*EOF - - - - - - - - - - - - - - - - - _ _ _ _ _ _ _ _ _ _ */
//AppDBGlobals. c — Application Database Globals; © 1997-8 Seth M Powsner #include <Pιlot.h>
DmOpenRef appDB; ULong appDBAppType;
Char appDBName [dmDBNameLength] ;
ULong appDBType;
/ΓÖªGeneric application ╬▒atabase globals addapted from MemoPad.c per Code amor Targettmg Palm OS v.x.2.1 pp.13 Modification nistory 980222 SMP cosmetic */ /*EOF - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
//AppDBGlobals. h; © 1997-8 Seth M Powsner extern DmOpenRef appDB; extern ULong appDBAppType; extern Char appDBName [dmDBNameLength] ; tdefine appDBNameDefault "AppTestDB" extern ULong appDBType;
ΓÖªdefine appDBTypeDefault 'Data' /*EOF - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
//AppDBInfoImt.c; © 1997-8 Seth M Powsner
#include <P╬╣lot.h> #include "AppGenericDefs . h"
#mclude "AppDBGlobals .h"
#mclude "AppDBInfoImt .h"
#include "AppGlobals .h"
#╬╣nclude "DBOpen.h" #╬╣nclude "GetResource.h" ΓÖªinclude "ResourceCommon.h" static char simplelnfo [] = "App DB info place holder"; Err AppDBInfolmt (DmOpenRef dbP) {
LocallD appInfoID;
VoidPtr appInfoP;
LocallD dbID; UInt cardNo;
VoidHand h;
// Get appInfoID given DmOpenRef via dbID and cardNo. if (DmOpenDatabaseInfo(dbP, SdblD, NULL, NULL, &cardNo, NULL) I i DmDatabaselnfo (cardNo, dbID, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, SappInfoID, NULL, NULL, NULL) ) return dmErrlnvalidParam; if (appInfoID == NULL) //create new applnfo if needed ( n = DmNewHandle (dbP, sizeof simplelnfo); if ( ' h) return dmErrMemError; appInfoID = MemHandleToLocallD (h) ;
DmSetDatabaselnfo (cardNo, dbID, NULL, NULL, NULL, NULL, NULL, NULL, NULL, SappInfoID, NULL, NULL,
NULL) ;
// Lock the appInfoID and copy n defaults from our default structure. appInfoP = MemLocallDToLockedPtr (appInfoID, cardNo); Dm rite (appInfoP, 0, ssimplelnfo, sizeof simplelnfo);
MemPtrUnlock (appInfoP) ; return OKreturnCode;
}
/ΓÖªGeneric database initialization a╬▒apted from MemoPad.c per CodeWarnor Targettmg Palm OS v.1.2.1 pp.13 Modification history 980222 SMP cosmetic
970926 SMP initial coding
*/
/*EOF - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ //AppDBInfolmt.h; © 1997-8 Seth M Powsner extern Err AppDBInfolmt (DmOpenRef dbP) ; /*EOF - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
//AppDBOpen.c — Application Database & Preference Open; © 1997-8 Seth M Powsner
ΓÖªinclude <P╬╣lot.h>
ΓÖªinclude "AppDBGlobals .h"
ΓÖªinclude "AppDBInfolmt .h"
ΓÖªinclude "AppDBOpen.h" ΓÖªinclude "AppGlobals .h"
ΓÖªinclude "dbOpen.h"
ΓÖªinclude "GetResource.h"
ΓÖªinclude "ResourceCommon.h" Err AppDBOpen (void)
{
SystemPreferencesType sysPrefs;
GetStringRscCopy (appDBName, primaryDBName, appDBNameDefault, sizeof (appDBName) ) ; appDBAppType = GetTypeResource (primaryDBAppType, appType) ; appDBType = GetTypeResource (primaryDBType, appDBTypeDefault) ;
PrefGetPreferences (SsysPrefs) ; if (' (appDB = DBOpen (appDBName, appDBType, appDBAppType, sysPrefs .hideSecretRecords ^ dmModeRead rite : (dmModeRead πte I dmModeShowSecret) ) ) ) return dmErrCantFmd; return AppDBInfolmt (appDB) ; } /♦Generic database open and preference open adapted from MemoPad.c per CodeWarnor Targettmg Palm OS v.1.2.1 pp.13
Modification history
980222 SMP cosmetic
970926 SMP initial coding */
/ΓÖªEOF - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ΓÖª/
//AppDBOpen.h ; © 1997-8 Seth M Powsner Err AppDBOpen (void) ;
/*EOF '_ - _ _ _ - _ - _ _ - - - - - - - _ _ - -. _ _ _ _ _ _ - _ */
//AppGeneπcDefs .h — Application Generic Definitions for convenience © 1997 Seth M Powsner ♦define OKreturnCode 0
ΓÖªdefine arrayLengtn (a) isizeof ╬╣a) /sizeof (a [0] ) )
/♦EOF - - _ _ _ - - _ - - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ */ //AppGlobals.c; © 1997-8 Seth M Powsner ♦include <Pιlot.h> ♦include "AppGlobals .h"
ULong appType; char appPreferences [appPrefLen] ; int appVersion;
/ΓÖªGeneric application globals, simplified from MemoPad.c per CodeWarnor Targettmg Palm OS v.1.2.1 pp.13 Modification history 980222 SMP cosmetic 970926 SMP initial coding
*/ /ΓÖªEOF - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
//AppGlobals. ; © 1997-8 Seth M Powsner extern ULong appType; ♦define appTypeDefault 'AppT'
ΓÖªdefine appPrefLen 64 extern char appPreferences [appPrefLen] ;
♦define appPrefDe ault "reirΛOxOOblank entry" extern int appVersion; ♦define appVersionDefault 100
/ΓÖª Generic Application Globals 971102 SMP version num * 100 970926 SMP initial */
/ΓÖªEOF _ _ _ _ _ _ _ */
//ApplicationHandleEvent . c — generic event application level event handler; © 1997-8 Seth M Powsner ♦include <Pιlot.h>
ΓÖªinclude "ApplicationHandleEven . h" ΓÖªinclude "Handlers. " Boolean ApplicationHandleEvent (EventPtr event) {
FormPtr formP; Int formN; Boolean handled = false; switch (event->eType)
{ case (frmLoadEvent) : formP = FrmIn╬╣tForm( formN = event->data. frmLoad. formID) ;
FrmSetAct╬╣veForm(formP) ;
FrmSetEventHandler (formP, FormHandlerTable (formN) ) ; handled = true; break; //case () :
// break;
return handled;
/ΓÖªModification history 980303 SMP cosmetic 970922 SMP initial */ /ΓÖªEOF - - - - - - - - - - -
/ /ApplicationHandleEvent. h © 1997-8 Setn M Powsner extern Boolean ApplicationHandleEvent (EventPtr event);
/ΓÖªEOF - - - - - - - - _ - - _ _ - _ _ _ _ _ _ _ _ _ _ _ _ _ */
//AppResourceList . c — allows correct loading of resource file; © 1997-
ParetoScope
ΓÖªinclude <Bu╬╣ldRules .h> // Application resources. char ΓÖªAppResourceList [ ] = (
":Rsc:" RESOURCE FILE PREFIX "Q20.rsrc",
/ΓÖªApplication Resource list module addapted from MemoPadRsc.c per CodeWarnor Targettmg Palm OS v.1.2.1 pp.13 Modifications
980303 SMP cosmetic 9 97711111155 S SMMPP reference BuildRules.n and let it set file prefix
971102 SMP Q20 put in
971012 SMP simplified version
*/
/ΓÖªEOF - _ _ _ '/
//AppResourceList . h © 1997- -8 ParetoS<
♦define StπngAlert 9000
ΓÖªdefine ThreeStrmgAlert 9001
ΓÖªdefine categoryConstan s 9950
ΓÖªdefine nameEtcForm 1000
ΓÖªdefine resultFor 1100
ΓÖªdefine thankYouFor 4100
ΓÖªdefine thankYouCode 90
ΓÖªde ine answerMultipliers 9
ΓÖªdefine lastName 10
ΓÖªdefine firstName 20
ΓÖªdefine clientNumber 30
ΓÖªdefine resultField 40
ΓÖªdefine resultText 90
/ΓÖª Specific Application Resource ID's
971122 SMP added result fields & specific forms
971121 SMP added categoryConstants
971102 SMP old Palm Tutorial definitions removed
971012 SMP initial based on Palm Tutorial 20 MemoPadRsc.h ΓÖª/ /ΓÖªEOF
//HandlerHelper . c - convert event fo to resource related mfo for FormElemHandler; © 1997-8 Seth M Powsner
ΓÖªinclude <P╬╣lot.h>
ΓÖªinclude "CommonFormGlobals . "
ΓÖªinclude "CommonFormGlobalFixup.h"
ΓÖªdefine ctlTypeListLen 6
ULong CtlTypeList [CtlTypeListLen] = t'tBTN', 'tPBN', ' tCBX ' , 'tPUT', 'tSLT'
'tREP' }; void CommonFormGlobalFixup (void) { elementRscType = ' ' ; elementID = 0; elementPtr = NULL; for ID = FrmGetActiveFormlDO , formPtr = FrmGetActiveFormt ) ; switch (event . eType) { //from Event. h enum events,
//case (mlEvent) :
//case (penDownEvent ) :
//case (penUpEvent) :
//case (penMoveEvent) :
//case (keyDownEvent) :
//case (winEnterEvent) :
//case (wmExitEvent) :
// break; case (ctlEnterEvent) : case (ctlExitEvent) : case (ctlSelectEvent) case (ctlRepeatEvent) case (popSelectEvent) // out of order from enum events, was after IstExitEvent elementID = event .data. ctlEnter . controlID; elementPtr = event . data . ctlEnter . pControl ; if (0<= ( (ControlPtr) elementPtr) ->style && ( (ControlPtr) elementPtr) ->style
< ctlTypeListLen) elementRscType ctlTypeList [ ( (ControlPtr) elementPtr) ->style] break; case (IstEnterEvent) : case (IstSelectEvent) : case (IstExitEvent) : elementRscType = 'tLST'; elementID = event .data. IstEnter. listID; elementPtr = event .data. IstEnter .pList; break; case (fldEnterEvent) : case (fldHeightChangedEvent) case (fldChangedEvent) : elementRscType = 'tFLD'; elementID = event .data. fldEnter. fieldID; elementPtr = event .data. fldEnter .pField; break; case (tblEnterEvent) : case (tblSelectEvent) case (tblExitEvent) : // out of order from enum events, was after frmCloseEvent elementRscType = 'tTBL'; elementID = event .data. tblEnter .tablelD; elementPtr = event .data. tblEnter .pTable; break;
case (daySelectEvent) break; case (menuEvent) : elementRscType = 'MENU'; elementID = event . data.menu. itemID; break;
//case (appStopEvent) :
//case (frmLoadEvent) :
//case (frmOpenEvent) :
//case (frmGotoEvent) :
//case (frmUpdateEvent) :
//case (frmSaveEvent) :
//case (fr CloseEvent) :
//case (tblExitEvent) : default break; }
}
/ΓÖªModification h.istory
980303 SMP cosmetic
970925 SMP initial
/ΓÖªEOF
//CommonFormGlobalFixup.h © 1997-8 Seth M Powsner extern void CommonFormGlobalFixup (void) ;
/ΓÖªEOF
//CommonFormGlobals . c — Commonly used form / event info; © 1997-8 Seth M Powsner
ΓÖªinclude <Pilot.h>
ΓÖªinclude "CommonFormGlobals.h"
Int elementID;
VoidPtr elementPtr;
ULong elementRscType
EventType event;
Int formID;
FormPtr formPtr;
/ΓÖªAdapted from MemoPad.c per CodeWarrior Targetting Palm OS v.1.2.1 pp.l.
Modification history
980303 SMP cosmetic
970925 SMP initial
*/
/ΓÖªEOF - - - - - - - - - - - - - - - _ _ _ _ _ _ _ _ _ _ */
//CommonFormGlobals.h © 1997-8 Seth M Powsner extern Int elementID; extern VoidPtr elementPtr; extern ULong elementRscType ; extern EventType event; extern Int formID; extern FormPtr formPtr;
/♦EOF - - - - - - - - - - - - - - - - - - //CustomHandlers.c; © 1997-8 ParetoScope
ΓÖªinclude <Pilot.h>
ΓÖªinclude "AppResourceList .h"
ΓÖªinclude "CommonFormGlobals . " ΓÖªinclude "CommonFormGlobalFixup.h" ΓÖªinclude "CustomHandlers .h"
ΓÖªinclude "GetResource.h"
ΓÖªinclude "Handlers. h"
ΓÖªinclude "ResourceCommon.h"
ΓÖªmclude "ScoreCalculation.h"
ΓÖªinclude "StoreFieldlnput .h"
ΓÖªinclude "Storelnput . "
Boolean NameEtcFormHandler (EventPtr eventP) {
Boolean handled = false; event = ΓÖªeventP; // Copy event data into CommonFormGlobals
CommonFormGlobalFixup ( ) switch (event .eType) { case (frmOpenEvent) : // Open, assume it's loaded & activated. // restore fields if needed
FrmDrawForm( formPtr) ; // Draw the form handled = true; break; case (ctlSelectEvent) : if (elementID - formID == nextButtonID) //"start" is a relabeled "next" button
Clearlnput ( ) ; // clear out checKboxes handled = FormElemHandler () ; // Leave rest to GeneπcControlHandler break; case (frmCloseEvent) : SaveFieldlnput () ; //handled = true; break; default: handled = FormElemHandler ( ) ; return handled; }
Boolean ResultFormHandler (EventPtr eventP) {
Boolean handled = false; event = ΓÖªeventP; // Copy event data into CommonFormGlobals
CommonFormGlobalFixup ( ) switch (event .eType) { case (frmOpenEvent) : // Open, assume it's loaded & activated.
ScoreCalculatio ( ) ; RestoreFieldlnput ( ) ; FrmDrawForm( formPtr) ; // Draw the form handled = true; break; case (ctlSelectEvent) : if (elementID - formID == backButtonlD) //"done" is a relabeled "back" button
ClearFieldlnput () ; // clear out name, etc handled = FormElemHandle () ; // Leave rest to
GenericControlHandler break; case (frmCloseEvent) :
// save fields if needed //handled = true; break; default: handled = FormElemHandler () ;
} return handled; Boolean ThankYouFormHandler (EventPtr eventP)
{ Boolean handled = false; char ΓÖª cp; event = ΓÖªeventP; // Copy event data into
CommonFormGlobals CommonFormGlobalFixup () ; switch (event . eType) { case (frmOpenEvent): // Open, assume it's loaded & activated. FrmDrawForm ( formPtr) ; // Draw the form handled = true; break; case ( keyDownEvent ) : cp = GetStrmgResource (formID + thankYouCode, "\26") ; if (event . data. keyDown. chr == ΓÖªcp)
{
FrmGotoForm(resultForm) ; handled = true; } UnlockStπngResource (1) ; break; default : handled = FormElemHandler () ; } return handled;
}
/ΓÖª Modification history 980222 SMP cosmetic 971122 SMP initial coding ΓÖª/ /ΓÖªEOF - - - - - - - - - - - - - - - - - - - - - - - - _ - - _ - */
//CustomHandlers.h S 1997-8 ParetoScope extern Boolean NameEtcFormHandler (EventPtr eventP); extern Boolean ResultFormHandler (EventPtr eventP); extern Boolean ThankYouFormHandler (EventPtr eventP);
/ΓÖªEOF - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
//DBDefaultCompare. c — passed to system routines to order database; © 1997- Seth M Powsner
ΓÖªinclude <P╬╣lot.h> ΓÖªinclude "AppDBGlobals .h" ΓÖªinclude "AppDBInfolmt .h" ΓÖªinclude "DBDefaultCompare . h"
ΓÖªdefine plsmaller -1 ΓÖªdefine equal 0 ΓÖªdefine pllarger 1 short DBDefaultCompare (void *pl, void *p2, /ΓÖª only first two parameters are used*/ short other, SortRecordlnfoPtr recpl,
SortRecordlnfoPtr recp2, VoidHand appInfoH)
ULong lenl;
ULong len2 ; short result; lenl = MemPtrS╬╣ze(pl) len2 = MemPtrSize (p2) if (lenl == 0) result = (len2 == 0) ? equal : plsmaller; else if (len2 == 0) result = pllarger; else for (result = equal, lenl = (lenl <= len2) ? lenl : len2; result == equal && lenl; ++( (CharPtr) pi) , ++( (CharPtr) p2) , ΓÇölenl) if (* (CharPtr) pi < * (CharPtr) p2) result = plsmaller; else if (* (CharPtr)pl > ΓÖª (CharPtr) p2) result = pllarger; return result; } /ΓÖªModification history
980222 SMP cosmetic changes
971115 SMP call sequence modified for new SDK
970928 SMP original
*/ /ΓÖªEOF - - - - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ */
//DBDefaultCompare. h;© 1997-8 Seth M Powsner extern DmComparF DBDefaultCompare/* see <DataMgr.h> ♦/;
/ΓÖªEOF
// DBOpen. c; © 1997-8 Seth M Powsner
ΓÖªinclude <P╬╣lot.h> // all the system toolbox headers
ΓÖªinclude "DBOpen. h"
DmOpenRef DBOpen (CharPtr dbName, ULong dbType, ULong appType, Ulnt mode)
Ulnt card;
LocallD dbID;
Ulnt dbAttrs;
DmOpenRef dbTempP ; dbTempP = DmOpenDatabaseByTypeCreator (dbType, appType, mode); if PdbTemoP && (mode > dmModeReadOnly)) // need to create datebase { if ( ' DmCreateDatabase (0 /*cardV, dbName, appType, dbType, false /ΓÖªnot resource*/) ) dbTempP = DmOpenDatabaseByTypeCreator (dbType, appType, mode); if ( ' DmOpenDatabaseInfo (dbTempP, &dbID, NULL, NULL, scard,
NULL)
&& 'DmDatabaseInfo(0, obID, NULL, idbAttrs, NULL, NULL,
NULL,
NULL, NULL, NULL, NULL, NULL, NULL)
{ dbAttrs |= dmHdrAttrBackup; // assume backup if (DmSetDatabaselnfo (0, dbID, NULL, &dbAttrs, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL) dbTempP = NULL; //something's wrong with new db
} } } return (dbTempP) ;
/ΓÖªGeneric routine for manipulating PalmOS database adapted from MemoPad.c per CodeWarrior Targettmg Palm OS v.1.2.1 pp.13 Modification history 980222 SMP cosmetic 970920 SMP initial
ΓÖª/
/ΓÖªEOF - - - - - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ */
// dbOpen.h; © 1997-8 Seth M Powsner extern DmOpenRef DBOpen (CharPtr dbName, ULong dbType, ULong appType, Ulnt mode) ;
/ΓÖªEOF ΓÖª/
//DBWnteOrdered. c— © 1997-8 Seth M Powsner
ΓÖªmclude <P╬╣lot.h>
♦mclude "AppDBGlobals .h" ♦include "AppGeneπcDefs .h"
ΓÖªinclude "DBDefaultCompare. h"
♦ include "dbWπteOrdered.h"
Err DBWnteOrdered (VoidPtr bufferP, ULong bufferLen, Int category)
Ulnt attr;
Err error;
Err errorTemp;
VoidHand h = = NULL;
Ulnt index = dmMaxRecordlndex
// copy buffer into new record at end of database and set category error = DmWrite (MemHandleLock (h = DmNewRecord (appDB, Smdex, bufferLen) ) , 0, bufferP, bufferLen) ; if ((errorTemp = MemHandleUnlock (h) ) ' = OKreturnCode && 'error) error = errorTemp; if ((errorTemp = DmReleaseRecord (appDB, xndex, true)) ' = OKreturnCode && 'error) error = errorTemp; if ('error) if ('(error = DmRecordlnfo (appDB, index, &attr, NULL, NULL))) { attr = (attr & ~dmRecAttrCategoryMask) | (category & dmRecAttrCategoryMask) ; if ('(error = DmSetRecordlnfo (appDB, index, &attr, NULL)))
// detach the record and insert it mto correct place // use same compare routine as for db sorting if ('(error = DmDetachRecord (appDB, index, &h) ) ) { index = DmFmdSortPositionVIO (appDB, MemHandleLock (h) ,
DBDefaultCompare, 0) ; if (' (error = MemHandleUnlock (h) ) ) error = DmAttachRecord (appDB, sindex, h, NULL);
return error;
)
/ΓÖªModification history 980303 SMP cosmetic 970928 SMP initial */ /ΓÖªEOF - - - - - - - - - - -
//dbWnteOrdered.h © 1997-8 Seth M Powsner extern Err DBWnteOrdered (VoidPtr bufferP, ULong bufferLen, Int category)
/ΓÖªEOF - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ΓÖª/
//DrawStrmglnBounds . c— Draw String in bounds (box) for lists; © 1997-8 Seth M Powsner
ΓÖªmclude <P╬╣lot.h>
♦include "drawStπnglnBounds . h" void DrawStrmglnBounds (CharPtr stπngP, RectanglePtr bounds)
Int textLen, width;
Boolean fits;
FontID currFont; currFont = FntSetFont (stdFont) ; // save and set font (a Pilot convention) width = bounds->extent .x - 2; // determine length of text that will fit textLen = StrLen (strmgP) ;
FntCharsInWidth (stringP, swidth, StextLen, &f╬╣ts) ;
WmDrawChars (strmgP, textLen, bounds->topLeft .x, bounds->topLeft . y) ; //draw it
FntSetFont (currFont) ; // restore the font
}
/ΓÖªGeneric Application Resource list module addapted from MemoPad.c per CodeWarrior Targettmg Palm OS v.1.2.1 pp.13 Modifications
980303 SMP cosmetic
971012 SMP simplified version
*/
/ΓÖªEOF - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
//DrawStrmglnBounds. h © 1997-8 Seth M Powsner extern void DrawStrmglnBounαs (CharPtr stringP, RectanglePtr bounds);
/♦EOF - - - - - - - - - - - - - - - - - - - - -. - - - _ - - - - */ //EventLoop. c — get and dispatch events 'till stopped; © 1997-8 Setn M Powsner
ΓÖª mclude <P╬╣lot.h>
ΓÖªinclude "ApplicationHandleEvent . h"
ΓÖªmclude "EventLoop. h" void EventLoop (void) {
Word error;
EventType event; do {
EvtGetEvent (sevent, evtWaitForever) ; if (SysHandleEvent (Sevent) ) continue; if (MenuHandleEvent (0, ievent, Serror) ) continue; if (ApplicationHandleEvent (Sevent) ) continue;
FrmDispatchEvent (Sevent) ; while (event. eType '= appStopEvent) ;
/ΓÖªGeneric application main routine adapted from MemoPad.c per CodeWarnor Targettmg Palm OS v.1.2.1 pp.13 980220 SMP cosmetic changes */
/ΓÖªEOF - - - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
//EventLoop. h © 1997-8 Seth M Powsner extern void EventLoop (void) ; /♦EOF - - - - - - - - - - - - - - - - - - - - - - - _ - - - - - */
/♦EOF - - - - - - - - - - - - - - _ - _ - _ - - - _ - - - - - - ♦/ //GenericControlHandler.c— Generic Control event Handler; © 1997-8 Seth M Powsner
♦include <Pιlot.h> ♦mclude "CommonFormGlobals . h" ♦include "GenencControlHandler .h" ♦include "GetResource.h" ♦include "ResourceCommon.h" ♦include "TestCode.h" static Boolean GotoFormSafely (int formID); Boolean GeneπcControlHandler (void) { int effectivelD; int formMultiple = GetlntResource (normalFormMultiple, formMultipleDefault) ;
Boolean handled = false; effectivelD = elementID >= formID elementID - formID : elementID % formMultiple; switch (event .eType) ( case (ctlSelectEvent) : switch (effectivelD) { case (nextButtonID) : {
GotoFormSafely (GetlntResource (formID -r nextFormSpec, formID + formMultiple) ) ; handled = true; break; } case (backButtonlD) : {
GotoFormSafely (GetlntResource (formID + pnorFormSpec, formID - formMultiple) ) ; handled = true; break; } case (restartButtonID) : { GotoFormSafely (GetlntResource (firstFormRscID, firstFormDefault) ) ; handled = true; break; } default:
{
GotoFormSafely (GetlntResource (formID -r nextFormSpec, formID + formMultiple) ) ; handled = true; }
} break; // ctlSelectEvent case done case (ctlRepeatEvent) : break; case (keyDownEvent) : switch (event .data. eyDown. chr) { case (pageUpChr) ΓÇó {
TestCode (formID) ; //if ( 'Testcode (form) )
// pageUpKeyProcess g ( ) ; handled = true; break; } case (pageDownChr) :
{
// pageDownKeyProcess g ( ) ; //handled = true; break; } default : {
//handled = true; break;
default: ; } return handled; Boolean GotoFormSafely (int formID) {
VoidHand tempH; if (firstFormDefault <= formID
&& formID <= GetlntResource (lastFormRscID, lastFormDefault) && NULL '= (te pH = DmGetlResource ' ' tFRM' , formID))) {
DmReleaseResource (tempH) ; FrmGotoForm ( formID) ;
} return NULL '= tempH;
}
/ΓÖª control handler to interpret any form's controls based on ResourceCommon.h 980303 SMP cosmetic
971116 SMP breakout debugging code and database code
971102 SMP implement some of generic functions
970925 SMP initial
*/
/ΓÖªEOF - _ - - - - - - - - - - - - - - - - - - - - - - - - - - _ */
//GeneπcControlHandler.h © 1997-8 Seth M Powsner extern Boolean GeneπcControlHandler (void) ;
/ΓÖªEOF - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ^/
//GeneπcFormHandler.c; © 1997-8 Setn M Powsner ♦include <Pιlot.h>
ΓÖªinclude "CommonFormGlobals.h"
ΓÖªinclude "CommonFormGlobalFixup.h"
ΓÖªinclude "GenencFormHandler . h"
ΓÖªinclude "Handlers. h"
ΓÖªmclude "Storelnput . h" //used in frmClose for checkbox storage
ΓÖªinclude "GetObjectPtr .h"
Boolean GenencFormHandler (EventPtr eventP) f
Boolean handled = false; int cID; //use╬▒ for cneckbox save and restore
ControlPtr ctlP; event = ΓÖªeventP; // Copy event data mto
CommonFormGlobals
CommonFormGlobalFixup ( ) ; switch (event . eType) { case (frmOpenEvent): // Open, assume it's loaded & activated.
// Initialize the form if needed if (2000 <= formID && formID <= 3900 // Not really generic
&& NULL '= (cID = Restorelnput (formID) ) && NULL '= (ctlP = GetOb3ectPtr (cID) ) ) CtlSetValue(ctlP, 1) ; FrmDrawForm ( formPtr) ; // Draw the form handled = true; break; case (frmCloseEvent) : // Not really generic, belongs in question form handler if (2000 <= formID && formID <= 3900) { for (cID = formID + 10; cID <= formID + 50; cID += 10) //save checkboxes if (CtlGetValue(ctlP = GetObjectPtr (cID) ) ) break; if (cID <= formID + 50) Savelnput (formID, cID) ; } break; default: handled = FormElemHandler () ;
} return handled; }
/* Modification history 980222 SMP cosmetic
971123 SMP Temporarily added checkbox save / restore code
970925 SMP Initial coding
*/
/ΓÖªEOF - - - - - - - - - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ */
/ /GenencFormHandler. h © 1997-8 Seth M Powsner extern Boolean GenencFormHandler (EventPtr event);
/ΓÖªEOF - - - - - - - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ */
// GetObjectPtr . c-- Get ilookup) Object's Pointer based on integer ID; © 1997-8 Seth M Powsner ♦include <P lot.h> ♦include "GetOb3ectPtr .h"
VoidPtr GetObjectPtr (Wor╬▒ objectID)
I
FormPtr frm;
Wor╬▒ ob3 Index; if ((objlndex = FrmGetNu berOfObjects (frm = FrmGetAct╬╣veForm( ) ) ) '= 0) do if (FrmGetOb3ectId(frm, ΓÇöobjlndex) == objectlD) return (FrmGetObjectPtr (frm, objlndex)); while (ob3 Index '= 0) ; return (NULL) ; }
/ΓÖªGeneric routine adapted from MemoPad.c per CodeWarrior Targettmg Palm OS v.1.2.1 pp.13 Modification history
980303 SMP cosmetic
970907 SMP modified from tutorial to make it safe for non-existent IDs
*/
/ΓÖªEOF - - - - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ */
//GetObjectPtr.h © 1997-8 Seth M Powsne extern VoidPtr GetObjectPtr (Word obiectID) ;
/♦EOF _ - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ //GetResource. c— Get (string and other) Resource (s) in coverted form; ©
1997-8 Seth M Powsner
ΓÖªinclude <P╬╣lot.h>
ΓÖªmclude "GetResource. h"
ΓÖªinclude "StrAToType.h" ΓÖªinclude "StrCopyN.h"
ΓÖªdefine tempHLen 8 static VoidHand tempH [tempHLen] ; static Int tempLast = tempHLen;
Int GetlntResource (Int RscID, Int notFoundReturn)
Int t; CharPtr p; p = GetStrmgResource (RscID, NULL); t = p ? StrAToI (p) : notFoundReturn; UnlockStπngResource (1) ; return t; CharPtr GetStnngResource (Int RscID, CharPtr notFoundReturn)
{ if (ΓÇötempLast < 0) return notFoundReturn; if ( ' (tempH [tempLast] = DmGetlResource (strRsc, RscID))) return notFoundReturn; return MemHandleLock (tempH [tempLast] ) ; }
CharPtr GetStringRscCopyN (CharPtr dst, Int RscID, CharPtr notFoundReturn, ULong size) {
StrCopyN (dst, GetStnngResource (RscID, notFoundReturn), size);
UnlockStnngResource (1) ; return dst; ) ULong GetTypeResource (Int RscID, ULong notFoundReturn) {
ULong type;
CharPtr p; p = GetStnngResource (RscID, NULL); type = p Γûá> StrAToType (p) : notFoundReturn; UnlockStnngResource (1) ; return type; ) void UnlockStnngResource (Int unlockCnt) ( if (unlockCnt > 0) ( if (tempLast < 0) if (unlockCnt + tempLast <= 0) tempLast += unlockCnt; unlockCnt = 0; } else unlockCnt += tempLast; tempLast = 0;
if (unlockCnt + tempLast > tempHLen) unlockCnt = tempHLen tempLast; for ' ; unlockCnt > 0 ; ++tempLast, --unlockCnt) if (tempH [tempLast] )
I
ErrNonFatalDisplaylf (
MemHandleUnlock (tempH [tempLast] , I I DmReleaseResource (tempH[tempLast] ) , "UnlkStrR failed"); tempH [tempLast] = NULL; }
/ΓÖªModification history
980304 SMP cosmetic
970925 SMP initial
*/
/ΓÖªEOF -
//GetResource. h © 1997-8 Seth M Powsner extern Int GetlntResource (Int RscID, Int notFoundReturn); extern CharPtr GetStnngResource (Int RscID, CharPtr notFoundReturn) extern CharPtr GetStringRscCopyN (CharPtr dst, Int RscID, CharPtr notFoundReturn, ULong size) ; extern ULong GetTypeResource (Int RscID, ULong notFoundReturn); extern void UnlockStnngResource (Int unlockCnt);
/♦EOF _ - _ - _ _ _ - - - - - - - - - - - - - - - _ _ - _ - - - ♦/ //GoToRecord. c — after Find function, may goto record; © 1997-8 Seth M
Powsner
ΓÖªinclude <P╬╣lot.h>
ΓÖªmclude "AppDBGlobals .h" ΓÖªinclude "GetResource. h"
ΓÖªmclude "GoToRecord. h" ΓÖªinclude "ResourceCommon.h" void GoToRecord (GoToParamsPtr goToParams, Boolean launchmgApp) {
Ulnt attr;
EventType event;
Ulnt goToForm;
Word recordNum; ULong umquelD; recordNum = goToParams->recordNum; // identify passed rec num DmRecordlnfo (appDB, recordNum, Sattr, suniquelD, NULL); if ('launchmgApp)
{
FrmCloseAllForms ( ) ; // assume app may be running and needs to clean up
DmFindRecordBylD (appDB, umquelD, &recordNum) ; // mease of re- ordering, use uni╬▒ue ID
)
// Send events to load and goto a form selecting the matching text. goToForm = GetlntResource (goToFormRscID, firstFormDefault) ;
MemSet (&event, sizeof (EventType) , 0) ; event . eType = frmLoadEvent; event .data. frmLoad. formID = goToForm; event. eType = frmGotoEvent; event .data. frmGoto. recordNum = recordNum; event .data. frmGoto.matchPos = goToParams->matchPos; event .data . frmGoto.matchLen = goToParams->searchStrLen; event .data. frmGoto. atchFieldNum = goToParams->matchF╬╣eldNum; event .data. frmGoto. formID = goToForm; EvtAddEventToQueue (Sevent) ; } /ΓÖªGeneric module addapted from MemoPad.c per CodeWarrior Targettmg Palm OS v.1.2.1 pp.13
Modification nistory
980221 SMP cosmetic
971012 SMP simplified version */
/ΓÖªEOF - - - - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ */
//GoToRecord. h © 1997-8 Seth M Powsner extern void GoToRecord (GoToParamsPtr goToParams, Boolean launchmgApp);
/ΓÖªEOF
//Handlers. c— modified for Emap; © 1997-8 ParetoScope ♦include <Pιlot.h> ♦include "AppResourceList .h" ♦include "CustomHandlers .h" ♦include "CommonFormGlobals.h" ♦include "GenencControlHandler . h' ♦include "Handlers. "
ΓÖªinclude "GenencFormHandler .h"
FormEventHandlerPtr FormHandlerTable (Int formN) { switch (formN) { // case (someSpecialForm) : return GenencFormHandler; // define in AppResourceList . h case (nameEtcForm) : return NameEtcFormHandler; case (resultForm) : return ResultFormHandler; case (thankYouForm) : return ThankYouFormHandler; default: return GenencFormHandler;
} } Boolean FormElemHandler (void) {
Boolean handled = false; switch (elementRscType) ( case CMBAR'): //Menu Bar (higher in
EventLoop. c) break; case ('MENU'): //Menu (item) switch (elementID) { default: handled = false;
} break; case CtBTN'): // Button switch (elementID) { default: switch (formID) t default: handled = GeneπcControlHandler ( } } break; case ('tCBX'): //Check Box switch (elementID) { default: handled = GenencControlHandler () ; } break; case CtFLD') : //Field switch (elementID) { default: ; } break; case ftPBN'): //Push Button switch (elementID) { default: handled = GeneπcControlHandler ( ) ; } break; case ('tPUT'): //Popup Trigger switch (elementID) ( default: ; } break; case ('tREP'): //Repeating Button switch (elementID) ( default: handled = GenencControlHandler ( ) ; } break; case CtSLT'): //Selector Trigger switch (elementID) { default: ; } break; case CtTBL') : //Table switch (elementID) { default : ; } default: handled = GenencControlHandler () ;
} return handled;
} /ΓÖª Form & Form Element handlers that may be customized Modifications
980304 SMP cosmetic
971102 SMP flxups
970924 SMP initial
/ΓÖªEOF -
//Handlers. h © 1997-8 ParetoScope extern FormEventHandlerPtr FormHandlerTable (Int formN) extern Boolean FormElemHandler (void) ;
/ΓÖªEOF
// Parse. c — parse (floating numbers); © 1997-8 Seth M Powsner ♦include <Pιlot.h> ♦include <ctype.h> ♦mclude "Parse. h" double ParseFloat (char ♦*p) { char *c = *p;
Boolean negative = false; double value = 0.0; double digitValue = 1.0;
SkipSpaces ( _c) , if Cc =='-') negative = true; C++;
) else if (*c == ' + ' )
C++; while CO' <= *c &i *c <= '9') // (lsdigit (ΓÖªc) ) value = value * 10.0 + (float) (*c++ - '0') if (*c == ' . ')
C++; while CO' <= ΓÖªc && ΓÖªc <= '9') // ds╬▒igit (ΓÖªc) )
{ digitValue *= 0.1; value += ( * c++ - '0 ') ΓÖªdigitValue;
return negative 7 -value : value; } // end parseFloat void SkipSpaces (cnar **p) { while (**p == ' ' II **p == '\f || **p == '\n') // (isspace (**p) (*P)++; return; }
/ΓÖª Modification history
980222 SMP cosmetic
971125 SMP Eliminate ischar for Pilot linking
971121 SMP Initial coding, Flp routines would not link correctly so.
/ΓÖªEOF - _ _ _ "I
//Parse. h © 1997-8 Seth M Powsner extern double ParseFloat (char *+p) ; extern void SkipSpaces (char **p) ;
/ΓÖªEOF
//PilotMain.c - called by emulator, returns error code; © 1997 Seth M Powsner ♦include <Pιlot.h> ♦include "AppGeneπcDefs.h"
ΓÖªinclude "AppDBmfoImt.h" ΓÖªinclude "EventLoop. h"
ΓÖªmclude "GoToRecord. h" ΓÖªinclude "ImtAppDBInfo.h" ΓÖªinclude "Search. h" ΓÖªinclude "StartApplication.h" ΓÖªinclude "StartForm.h" ΓÖªinclude "StopApplication.h" ΓÖªinclude "SyncNotification.h"
DWord P╬╣lotMam(Word cmd, Ptr cmdPBP, Word launchFlags) { switch (cmd) { // commands are defined in SystemMgr.h case (sysAppLaunchCmdNormalLaunch) : if (StartApplication ( ) == OKreturnCode) {
StartFormO; // start / restart EventLoop ( ) ;
StopApplication ( ) , } break; case (sysAppLaunchCmdFmd) :
Search ( (FmdParamsPtr) cmdPBP) ; break; case (sysAppLaunchCmdGoTo) : if (launchFlags & sysAppLaunchFlagNewGlobals)
( if ('StartApplication ()) {
GoToRecord ( (GoToParamsPtr) cmdPBP, true); EventLoop ( ) ;
StopApplication ( ) ; } } else GoToRecord ( (GoToParamsPtr) cmdPBP, false); //running, just show record break; case (sysAppLaunchCmdSaveData) : FrmSaveAllForms ( ) ; //save data, possibly sort db before possiole find break; case (sysAppLaunchCmdSyncNotify) : SyncNotification () ; //may need to recheck db break; case (sysAppLaunchCmdlnitDatabase) : //need to fixup app data in db (eg, categories) AppDBInfolmt ( ( (SysAppLaunchCmdlnitDatabaseType^) cmdPBP) ->dbP) ; break; ) return 0; } /ΓÖªGeneric application mam routine adapted from MemoPad.c per CodeWarrior Targettmg Palm OS v.1.2.1 pp.13 Modification history 980220 SMP cosmetic changes 970922 SMP initial ΓÖª/
/ΓÖªEOF _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ */
// ResourceCommon.h © 1997-8 Seth M Powsner // tSTR resource ID's used to navigate forms and control application ♦define firstFormRscID 9999 ♦define flrstFormDefault 1000 ♦define normalFormMultiple 9998 // normal increment between forms
ΓÖªdefine formMultipleDefault 100 ΓÖªdefine lastFormRscID 9997 ΓÖªdefine lastFormDefault 8900 ΓÖªdefine appTypeRsc 9996
♦αefme appVersionRsc 9995 ♦define appHeaderStr 9994 // for system find invocations ♦define goToFormRscID 9993 ♦define categoryOODefaultName 9989 ♦define categoryOlDefaultName (categoryOODefaultName-1) ♦define category02DefaultName (categoryOODefaultName-2) ♦define category03DefaultName (categoryOODefaultName-3) ♦define category04DefaultName (categoryOODefaultName-4 ) ♦define category05DefaultName (categoryOODefaultName-5) ♦define categoryOδDefaultName (categoryOODefaultName-6) ♦define category07DefaultName (categoryOODefaultName-7) ♦define category08DefaultName (categoryOODefaultName-8) ♦define category09DefaultName (categoryOODefaultName-9) ♦define categorylODefaultName (categoryOODefaultName-10) ♦define categoryllDefaultName (categoryOODefaultName-11^ ♦define categoryl2DefaultName (categoryOODefaultName-12) ♦define categoryl3DefaultName (categoryOODefaultName-13) ♦define category 4Defau tName (categoryOODefaultName-14 ) ♦define categoryl5DefaultName (categoryOODefaultName-15) ♦define primaryDBName 9973
♦define pπmaryDBType (prιmaryDBName-1) ♦define primaryDBAppType (pnmaryDBName-2 ) ♦define secondaryDBName (prιmaryDBName-3) ♦define secondaryDBType (prιmaryDBName-4 ) ♦define secondaryDBAppType (pnmaryDBName-5) ♦define tertiaryDBName (primaryDBName-6) ♦define tertiaryDBType (prιmaryDBName-7 ) ♦define tertiaryDBAppType (primaryDBName-8)
// tSTR resources wnose IDs' are relative to each forms ' ID
ΓÖªdefine answerLabelforForm 0 // answer label instead of formID as string
ΓÖªdefine nextFormSpec 1 // when normal increment not desired,
// -1 not allowed
ΓÖªdefine pnorFormSpec 2 // when normal decrement not desired,
// -1 not allowed, -2 for pop
/ΓÖª tSTR resources wnose IDs' are relative to each form element's ID (or group ID) so individual resource, then group, then form's tSTR's are searched group IDs are added to from ID to make an effective resource ID form input element resource ID's should go by 10 's if a element's ID is less than the form ID, then offset if MOD multiple group ID is handled as usual home form for element / group is used as back up at element & group steps */
ΓÖªdefine answerValue 0 // string value to use instead of implicit
ΓÖªdefine answerLabel 1 // answer label instead of form label
ΓÖªdefine answerDefauit 2
ΓÖªdefine answerMaximum 3
ΓÖªdefine answerM imum 4 ΓÖªdefine answerJump 5 // 0 no, -1 yes to form default, FormID
ΓÖªdefine mustAnswer 6
ΓÖªdefine freshAnswer 7
// form elements with default mtpretations if there is no associated tSTR ΓÖªdefine nextButtonID 1 // IDs offset from formID
ΓÖªdefine backButtonlD 2
ΓÖªdefine restartButtonID 3 xx /* Resource ID map
<= 999 System, according to Tutorial 1.2.2
1000 first form based on CW Constructor
1010 first element m first form
1020 second element, etc
1098 second fixed item, etc
1099 first fixed item in first from, working down
1100 second form 1200 third from, etc 9998 tSTR ╬▒ata
9999 tSTR ╬▒ata for general form processing, works down
> 9999 System, oased on SystemMgr.H
'/
/ΓÖªModification history 980304 SMP cosmetic 970923 SMP Initial ΓÖª/ /ΓÖªEOF - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
//SaveRestoreFie d. c — save ana restore chars in a field; © 1997-8 Seth M Powsner
ΓÖªinclude <P╬╣lot.h> ΓÖªinclude "GetObjectPtr .h"
ΓÖªinclude "SaveRestoreFieid. h" ΓÖªinclude "StrCopyN.h" void SaveField (mt ObjectID, char *cp, ULong maxFieldChars) {
FieldPtr fldP; if (NULL '= (fldP = GetObjectPtr (ObjectID) ) ) ( FldCompactText (fldP) ;
StrCopyN(cp, FldGetTextPtr (fldP) , fldP->textLen > 0 Γûá> maxFieldChars : 0) ;
} ) void RestoreField ( t ObjectID, cnar ΓÖªcp) (
FieldPtr fldP; VoidHand tempH; if (NULL '= (fldP = GetObjectPtr (ObjectID) )
&& NULL '= (tempH = MemHandleNew (fldP->maxChars) ) )
{
StrCopy (MemHandleLock (tempH) , cp, fldP->maxChars) ;
MemHandleUnlock (tempH) ; FldSetTextHandle(fldP, tempH) ;
//FldDrawField (fIdP) ; // but not need before form draw
/ΓÖªModification history
980222 SMP initial file
ΓÖª/
/♦EOF _ _ _ - _ - - - - - - - - - - - - - - - - - - - - - - - - ♦/ //SaveRestoreFieid. h © 1997-8 Seth M Powsner extern void SaveFιeld(mt Ob ectID, char ♦cp, ULong maxFieldChars); extern void RestoreField ( t ObjectID, char ♦cp) ;
/♦EOF _ _ _ _ _ _ _ _ _ _ _ _ _ _ */ //ScoreCalculation. c — calculate EnrichMap category score; ©1997-8 Paretoscope
ΓÖªmclude <P╬╣lot.h>
ΓÖªmclude "AppResourceList .h" ΓÖªinclude "GetResource. h"
ΓÖªinclude "Parse. h"
ΓÖªinclude "ScoreCalculation. "
ΓÖªinclude "Storelnput .h" mt likelyCategory; double score [categories] ; void ScoreCalculation (void)
{ char *c; t formID; t elementID; t l; for (I = 0; I < categories; ╬╣++) score [I] = 0.0; if (NULL '= (c = GetStnngResource (categoryConstants, NULL))) ( for (╬╣ = 0; l < categories; ╬╣++) score [l] = ParseFloat (&c) ; UnlockStnngResource (1) ; } for (Firstlnput (SformlD, .elementID); formID; Nextlnput ( .formID,
&elementID) ) ( if (NULL '= (c = GetStnngResource (formID + 10 + answerMultipliers,
'))) for (l = 0; l < categories; ╬╣++) scored] += ParseFloat (&c) ΓÖª ((elementID - formID) / 10) UnlockStnngResource (1) ; }
for (I = likelyCategory = categories - 1; ΓÇöl >=0; ) if (score [likelyCategory] < score [I] ) likelyCategory = I; return;
/ΓÖªModification history 980221 SMP cosmetic 971124 SMP initial coding */ /ΓÖªEOF - - _ _ - _ - - - _ _ _
//ScoreCalculation. h ®1997-8 Paretoscope extern void ScoreCalculation (void
ΓÖªdefine categories 6 extern int likelyCategory; extern double score [ categories ] ;
/ΓÖªEOF
//Search. c — find a record, invoked by system Find feature; © 1997-8 Seth M
Powsner
ΓÖªinclude <P╬╣lot.h> ΓÖªinclude "AppDBClose.h"
ΓÖªinclude "AppDBGlobals .h"
ΓÖªinclude "AppDBOpen.h"
ΓÖªinclude "ResourceCommon.h"
ΓÖªinclude "drawStrmglnBounds . h" ΓÖªinclude "GetResource. h" ΓÖªinclude "Search . h" void Search (FindParamsPtr f dParams)
{ VoidPtr appDBRecP;
Ulnt cardNo;
LocallD dbID;
Boolean full;
CharPtr header; Word pos; RectangleType r;
VoidHand recordH;
Ulnt recordNum; if (AppDBOpenO I! DmOpenDatabaselnfo (appDB, sdblD, 0, 0, &cardNo, 0)) fmdParams->more = false; // no point in bemg called further if DB does not open else { header = GetStnngResource (appHeaderStr, "Application"); //set heading full = FmdDrawrieader (fmdParams, header); UnlockStnngResource (1) ; for ( recordNum = f╬╣ndParams->recordNum; //pickup checking records where told
NULL '= (recor╬▒H = DmQueryNextlnCategory (appDB, SrecordNum, dmAllCategories) )
&& 'full; recordNum++)
{ if (FmdStrlnStr (appDBRecP = MemHandleLock (recordH) , fmdParams->strToFmd, &pos) ) { if (true == (full = FmdSaveMatcn (fmdParams, recordNum, pos, 0, 0, cardNo, dbID) ) ) recordNum--; // need to visit this record again else f // Get the bounds of the region where we will draw the results .
FmdGetLmeBounds (fmdParams, &r) ; // Display the record in the search dialog. We move in one pixel // so that when the record is inverted the left e╬▒ge is solid. . topLeft . x++; r . extent .xΓÇö ;
DrawStrmglnBounds (appDBRecP, &r) ; // line is used for the record. fmdParams->l╬╣neNumber++ ;
} MemHandleUnlock (recordH) ; fmdParams->more = (NULL '= recordH);
AppDBClose ( ) ;
/ΓÖªGeneric module addapted from MemoPad.c per CodeWarrior Targettmg Palm OS v.1.2.1 pp.13 Modification history
980221 SMP changed stopping logic 971012 SMP simplified version ΓÖª/ /ΓÖªEOF - - - - _ - - - - - - - - - - - - - - - - - - - - _ - - - ΓÖª/
//Search. h © 1997-8 Seth M Powsner extern void Search (FindParamsPtr fmdParams) ; /♦EOF - - - - - - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ */
//Serial. c — serial interface test code; © 1997-8 Seth M Powsner ♦include <Pιlot.h> //♦include <SerιalLιbMac.h> ♦include <SerιalMgr .h>
♦define serialPortNum 0 ♦define defaultBaudRate 57600 ♦define testMsg "Abe Def\r\n" static Int openStatus = false; static Ulnt senalLibRefNum; extern void SerialTest (void) ; static Err Seπallnit (void)
Err error = false; if ( ' openStatus) if ('(error = SysLibFind ("Serial Library", .senalLibRefNum))) if ('(error = SerOpen (senalLibRefNum, serialPortNum, defaultBaudRate) ) ) openStatus = true; return error; } voi╬▒ SerialTest (void) {
ErrNonFatalDisplaylf (Seriallmt () , "Seπallnit trbl.");
ErrNonFatalDisplaylf (SerClearErr (senalLibRefNum), "SerClearErr trbl."); // no error returned, just clears
ΓÖªif EMULATION_LEVEL == EMULATION_NONE
ErrNonFatalDisplaylf (SerSendVlO (senalLibRefNum, testMsg, sizeof (testMsg) )
, "SerSend trbl. ") ; ErrNonFatalDisplaylf (SerSendWait (senalLibRefNum, serDefaultCTSTimeout ) , "SerSendWait trbl."); //5^sysT╬╣cksPerSecond
ΓÖªendif ErrNonFatalDisplaylf (SerClose (senalLibRefNum)
, "SerClose trbl ") ; // serErrNotOpen may not be error }
/ΓÖªModification history 980221 SMP cosmetic 971115 SMP initial coding */
/ΓÖªEOF - - _ _ _ - - - - - - - - - _ - - - - - - - - - - - - - - */
//StartApplication. c -- initialization, including opening mam database; © 1997-8 Seth M Powsner ♦include <Pιlot.h>
ΓÖªinclude "AppGlobals .h" ΓÖªinclude "AppDBGlobals .h"
ΓÖªmclude "AppDBOpen.h" ΓÖªinclude "GetResource. h" ΓÖªinclude "ResourceCommon.h"
ΓÖªinclude "StartApplication. h"
ΓÖªinclude "StoreFieldlnput .h"
ΓÖªmclude "StrCopyN.h" Boolean StartApplication (void) {
//SystemPreferencesType sysPrefs;
//PrefGetPreferences (SsysPrefs) ; appType = GetTypeResource (appTypeRsc, appTypeDefault) ; appVersion = GetlntResource (appVersionRsc, appVersionDefault) ; if ( i PrefGetAppPreferencesVlO (appType, appVersion, appPreferences, sizeof (appPreferences) ) ) { StrCopyN (appPreferences, appPrefDefault, sizeof (appPreferences). '
PrefSetAppPreferencesVIO (appType, appVersion, appPreferences, sizeof (appPreferences) ) ; }
// Clear out name fields ClearFieldlnput ( ) ; return AppDBOpen ( ) ; }
/ΓÖªGeneric routine adapted from MemoPad.c per CodeWarnor Targettmg Palm OS v.1.2.1 pp.13
980221 SMP cosmetic cnanges */ /ΓÖªEOF - - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ */
//StartApplication. h © 1997-8 Seth M Powsner extern Boolean StartApplication (void) ; /*EOF - - - _ - - _ - - - - - - - - - - - - - - - - - _ - - - - */
//StartForm. c -- go to first form based on resource definitions; © 1997-8 Seth M Powsner ♦include <Pιlot.h> ♦include "GetResource . n"
ΓÖªmclude "ResourceCommon.h" ΓÖªinclude "StartForm. h" void StartForm(void) {
FrmGotoForm (GetlntResource (firstFormRscID, firstFormDefault ) ) ; }
/ΓÖªGeneric application mam routine adapted from MemoPad.c per CodeWarrior Targettmg Palm OS v.1.2.1 pp.13
980220 SMP cosmetic changes */ /♦EOF _ - - - - - - - - - - - - - - - - - - - _ - - - - - - - - */ //StartForm. h © 1997-8 Seth M Powsner extern void StartForm(voιd) ;
/♦EOF - - - - - - - - - - - - - - - - - - - - _ - - - - - _ - - ♦/ //StopApplication. c — oackout things setup in StartApplication; © 1997-8
Seth M Powsner
ΓÖªinclude <P╬╣lot.h>
♦include "AppGlobals . π"
ΓÖªinclude "AppDBClose . n" ΓÖªinclude "StopApplication. h" void StopApplication (void) { FrmCloseAllForms ( ) , // frmCloseEvent to all forms (outside of
EventLoop control)
// Close database
ErrNonFatalDisplaylf (AppDBClose () , "Trouble closing DB.");
// Save preferences & state initialized in StartApplication PrefSetAppPreferencesVIO (appType, appVersion, appPreferences, sizeof (appPreferences) ) ; }
/ΓÖªGeneric routine adapted from MemoPad.c per CodeWarrior Targettmg Palm OS v.1.2.1 pp.13 Modification History 980221 SMP cosmetic changes 971115 SMP V10 call for compatibility under new SDK 970927 SMP original adapted from Tutorial
/ΓÖªEOF */
//StopApplication. © 1997-8 Seth M Powsner extern void StopApplication (void) ;
/ΓÖªEOF _ - - - - - - - - - - - - - - - _ _ _ -
//StoreFieldlnput . c — store and restore) name fields, etc; © 1997-
ParetoScope
ΓÖªinclude <P╬╣lot.h>
♦include "AppGeneπcDefs .h" ♦include "AppResourceList ,h" ♦include "CommonFormGlobals.h"
ΓÖªmclude "GetResource. h"
ΓÖªmclude "SaveRestoreFieid. h" ΓÖªinclude "ScoreCalculation. h" ΓÖªinclude "StoreFieldlnput .h" mt f╬╣eldL╬╣st[] = (lastName, firstName, clientNumber } ; const int maxFieldChars = 32; char fieldStrmg [arrayLength (fieldList) ] [maxFieldChars] ; void ClearFieloInput (void) t l ; for (l = arrayLength (fieldList) ; -i >= 0; ) f╬╣eldStr╬╣ng[╬╣] [0] = '\0'; void SaveFieldlnput (void) t l ; for (I = arrayLength (fieldList) ; ΓÇöI >= 0; )
SaveField ( fieldList [l] + formID, fieldStrmg [1] , maxFieldChars) void RestoreFieldlnput (void) mt l ; for (l = arrayLength (fieldList) ; ΓÇöI >= 0; )
RestoreField (fieldList [I] + resultForm, ieldStrmg [l] ) ; RestoreF╬╣eld(resultF╬╣eld + resultForm, GetStnngResource (likelyCategory + resultText + formID,
"Error. Please report."));
UnlockStnngResource (1) ; } /* Modification history
980222 SMP separated out low level Pilot calls, & cosmetic fixes
971125 SMP Use likelyCategory to set response
971123 SMP Initial coding
*/ /ΓÖªEOF - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
//StoreFieldlnput. h © 1997-8 ParetoScope extern void ClearFieldlnput (void) ; extern void SaveFieldlnput (void) ; extern void RestoreFieldlnput (void) ;
/ΓÖªEOF - - - - - _ _ _ - - - - - - - - - _ - - - - - - - - - _ - */
//Storelnput. c — store inputs from form; © 1997-8 Seth M Powsner ♦include <Pιlot.h>
ΓÖªmclude "Storelnput .h" const tableLen = 29; //should be prime typedef struct { mt formID; mt elementID; } formElementPair; const empty = 0; static formElementPair table [tableLen] ; Boolean tablelmtialized = false; formElementPair ΓÖªpossibleEntry (mt formID); void Clearlnput (void) { tablelmtialized = false;
} void Savelnput ( mt formID, mt elementID) { formElementPair ^p; ErrFatalDisplaylf (NULL == (p = possibleEntry ( formID) )
I I (p->formID '= formID && p->formID '= empty), "Input table overflow."); p->formID = formID; p->elementID = elementID; return;
} mt Restorelnput (mt formID) { formElementPair *p = possibleEntry (formID) ; return p && p->formID == formID *> p->elementID : NULL; } formElementPair ΓÖªpossibleEntry (mt formID) { int probe, toCheck; if ('tablelmtialized) tablelmtialized = true; for (probe = tableLen; ΓÇöprobe >=0;) table [probe] . formID = empty; } for (probe = formID % tableLen, toCheck = tableLen;
ΓÇötoCheck >= 0 && table [probe] .formID '= empty && table [probe] . formID '= formID; prooe = (probe + 1) % tableLen) return Stable [probe] ;
int nextPair = -1; void Firstlnput ( t ΓÖªformlDp, mt ΓÖªelementlDp) { nextPair = tableLen - 1;
Nextlnput (formlDp, elementlDp); } void Nextlnputdnt ΓÖªformlDp, mt ΓÖªelementlDp) while (nextPair >= 0 && table [nextPair] . formID == empty) ΓÇönextPair; if (nextPair >= 0)
{
ΓÖªformlDp = table [nextPair] . formID; ΓÖªelementlDp = table [nextPair] . elementID; ΓÇönextPair; } else
ΓÖªformlDp = ΓÖªelementlDp = empty; return; } /ΓÖª Modification history 980222 SMP cosmetic
971121 SMP Initial coding, simple hash design, element ID only ΓÖª/ /ΓÖªEOF _ _ _ */
//Storelnput. h © 1997-8 Seth M Powsner extern void Clearlnput (void) ; extern void Firstlnput (mt ♦formlDp, mt ♦elementlDp); extern void Nextlnputdnt ♦formlDp, mt ♦elementlDp); extern void Savelnput (int formID, int elementID); extern int Restorelnput (mt formID);
/ΓÖªEOF - - - - - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ */
//StrAToType. c — convert ascn to "type" type; © 1997-8 Seth M Powsner ♦mclude <Pιlot.h>
ΓÖªinclude "StrAToType. h" ULong StrAToType (CharPtr str) {
Int n;
CharPtr p;
ULong type = ' ' ; for (n = sizeof (type) , p = (CharPtr) &type; ΓÇön >= 0 & *str; ; ΓÖªp++ = ΓÖªstr++; return type; } /ΓÖªModification history
980222 SMP cosmetic
*/
/♦EOF - - - - - - - - - //StrAToType.h © 1997-8 Seth M Powsner extern ULong StrAToType (CharPtr str); /♦EOF - - _ _ _ _ _ _ _ _ _ _ _ _
//StrCopyN. c -- string copy with limit; © 1997-8 Seth M Powsner ♦include <Pιlot.h>
ΓÖªmclude "StrCopyN. h"
CharPtr StrCopy (CharPtr dst, CharPtr src, ULong n) { if (n '= 0) while (ΓÇön && (*dst++ = *src++) '= 0) ; if (n == 0) *dst++ = NULL; return dst; }
/ΓÖªModification history 980221 SMP cosmetic
970926 SMP initial coding (st╬▒ function, but not on Pilot) */ /ΓÖªEOF - - - - - - - - - - - - - _ _ _ _ _ _ _ _ _ _ _ _ */
//StrCopyN. h © 1997-8 Seth M Powsner extern CharPtr StrCopyN (CharPtr dst, CharPtr src, ULong n) ;
/ΓÖªEOF - - - - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ */
//SyncNoti ication. c — let application know about syncronizations; © 1997-
Seth M Powsner
ΓÖªinclude <P╬╣lot.h>
ΓÖªinclude "SyncNotification.h"
Err SyncNotification (void) //dummy routine { return (0) ; /ΓÖªGeneric routine adapted from MemoPad.c per CodeWarrior Targettmg Palm OS v.1.2.1 pp.13
Modification history
980221 SMP cosmetic
*/
/ΓÖªEOF - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
//SyncNotification.h © 1997-8 Setn M Powsner extern Err SyncNotification (void) ;
/ΓÖªEOF
//TestCode.c— generic Test Code routine stub; © 1997-8 Seth M Powsner ♦include <Pιlot.h> ♦include "AppResourceList. h" ♦include "TestCode.h"
Boolean TestCodednt formID)
{ //SoundManager . h
SndPiaySystemSound (sndWarmng) ; //to signal code bemg tested //add code here return true;
) /ΓÖªModification history
980303 SMP cosmetic
971120 SMP initial use
*/
/ΓÖªEOF - - - - - - - - - - - - - _ _ _ _ _ _ _ _ _ _ _ _ */
//TestCode.h © 1997-8 Seth M Powsner
Boolean TestCodednt formID);
/♦EOF - - - - - - - - - - - - - - - - - - - - - - - - _ _ - */ //ToStr.c — various type to string conversions; © 1997-8 Seth M Powsner ♦include <Pιlot.h> ♦include <NewFloatMgr .h> ♦include "ToStr.h" static char ♦ StrUToA2 (char ♦p, ULong u, Boolean leadmgZero) ; static cnar convertBuf [8] [12] ; static Word convertBufNext = 0; ♦define convertBufNextMask 7; cnar ♦ FloatToSt (double di {
FlpCo pDouble ΓÖªp = (void ΓÖª) &d; convertBufNext = (convertBufNext + 1) & convertBufNextMask; FlpFToA(p->fd, convertBuf [convertBufNext ]) ; return convertBuf [convertBufNext] ; } char ΓÖª IntToStr (/*long*/╬╣nt i) { convertBufNext = (convertBufNext + 1) & convertBufNextMask; return StrlToA (convertBuf [convertBufNext] , l) ; char ΓÖª ULongToStr (ULong i) { convertBufNext = (convertBufNext + 1) & convertBufNextMask; return StrUToA2 (convertBuf [convertBufNext] , I, false); char * ULongToStrFixed (ULong I) { convertBufNext = (convertBufNext + 1) & convertBufNextMask; return StrUToA2 (convertBuf [convertBufNext] , I, true); } static ULong powersOfTen[ ] = (1000000000, 100000000, 10000000, 1000000, 100000, 10000, 1000, 100, 10,
0) char ΓÖª StrUToA2 (char *p, ULong u, Boolean leadingZero) { char ΓÖªdp = p; int i;
ULong ΓÖªtenp; for (tenp = &powersOfTen[0] ; ΓÖªtenp; tenp++)
{ i = (int) (u/ (*tenp) ) ; leadingZero |= (i != 0) ; if (leadingZero)
*dp++ = ("0123456789") [i] ; u -= i * (ΓÖªtenp) ;
} ΓÖªdp++ = ("0123456789") [u] ; ΓÖªdp++ = 'u' ; ΓÖªdp = NULL; return p;
}
/ΓÖªModification history 980222 SMP cosmetic
971115 SMP added StrUToA & StrUtoAFixed
971113 SMP renamed ToStr.c, ULongToStr added;
970921 SMP separated out
*/ /ΓÖªEOF - - - - _ - - - - - - - - - - _ - - - - - - - -
//ToStr.h © 1997-8 Seth M Powsner extern char ♦ FloatToStr (double d) ; extern char ♦ IntToStr ( longVint i) ; extern char ♦ ULongToStr (ULong i) ; extern char ♦ ULongToStrFixed (ULong i) ;
/ΓÖªEOF