Does anyone know how to assign a structure array to
a moveable chunk?  I think I've got the general concept.

Here is the essence of the problem cut and pasted from my application.
(This is for prostate cancer research, by the way.  Thus the surgical
jargon).  The last function is the one I'm having trouble with.
I think I included just enough to help you make sense of the problem.

TIA,
Paul Fearn
Memorial Sloan-Kettering Cancer Center


......................................

static VoidHand lookupTableHandle;

#define NUMBER_PARTIN_ROWS 140
#define NA      -9

// Clinical Stages
#define T1a     0
#define T1b     1
#define T1c 2
#define T2a     3
#define T2b 4
#define T2c 5
#define T3a 6


typedef struct {
        // 22-bytes per record
        Word gleasonMin;  // minimum Gleason total for this strata
        Word gleasonMax;  // maximum Gleason total for this strata
        Word tumorStage;  // UICC tumor stage
        float psaMin;   // minimum PSA for this strata
        float psaMax;   // maximum PSA for this strata
        Word ocdScore;  // Partin probability of organ confined disease
        Word ecpScore;  // Partin probability of extra capsular penetration
        Word sviScore;  // Partin probability of seminal vesicle
involvement(invasion)
        Word lniScore;  // Partin probability of lymph node involvement (invasion)
        } partinTable;

// variable declarations
static Word wPPOCD;             // Partin probability of organ-confined disease
static Word wPPECP;             // Partin probability of extra capsular extension
static Word wPPSVI;             // Partin probability of seminal vesicle invasion
static Word wPPLNI;             // Partin probability of lymph node involvement


// functions
static Err AppStart(void)
{       
        // allocate a moveable chunk of memory large enough for entire lookup table.
        lookupTableHandle = MemHandleNew(sizeof(partinTable)*NUMBER_PARTIN_ROWS);
        if (lookupTableHandle == NULL) 
                FrmCustomAlert(InformAlert, "Handle was null",NULL, NULL);
}

static void AppStop(void)
{
   // free up the moveable chunk used for lookup tables
   MemHandleFree (lookupTableHandle);
}

static void partinLookup (Word gleason, Word tumorStage, float psa)
{
        Word i;
        // ************** HERE IS THE FIRST PROBLEM *********************
        // what syntax do I use to place this huge structure array
        // into the moveable chunk?

        // SomeKindOfPointer = MemHandleLock(lookupTableHandle)
        
        // this table takes up 3080-bytes (22-bytes x 140 elements)
        
        // *************** NEXT PROBLEM *********************************
        // how do I assign these values to that array?
        // originally, this was just assigned like this...
        // static partinTable[NUMBER_PARTIN_ROWS] = {   

                { 2, 4, T1a, 0, 4, 90, 9, 0, 0 },
                { 2, 4, T1a, 4, 10, 84, 14, 1, 0 },
                { 2, 4, T1a, 10, 20, 76, 20, 2, 0 },
                { 2, 4, T1a, 20, 9999, NA, NA, NA, NA },
                { 2, 4, T1b, 0, 4, 80, 19, 1, 0 },
                { 2, 4, T1b, 4, 10, 70, 27, 2, 1 },
                ............ 140 rows of this.........
                { 2, 4, T1b, 10, 20, 58, 36, 4, 2 },
                { 2, 4, T1b, 20, 9999, 38, 47, 9, 4 },
                { 2, 4, T1c, 0, 4, 89, 10, 1, 0 },
                { 2, 4, T1c, 4, 10, 83, 15, 1, 0 },
                { 2, 4, T1c, 10, 20, 75, 22, 2, 0 },
                { 2, 4, T1c, 20, 9999, 58, 34, 7, 1 },
                };
                        
                for ( i = 0; i < NUMBER_PARTIN_ROWS ; i++) {
                if (gleason >= lookup[i].gleasonMin && gleason <= lookup[i].gleasonMax)
                        if (tumorStage == lookup[i].tumorStage)
                                if (psa >= lookup[i].psaMin && psa <= 
lookup[i].psaMax) {
                                        // if this is the right row, assign all scores
                                                wPPOCD = lookup[i].ocdScore;
                                                wPPECP = lookup[i].ecpScore;
                                                wPPSVI = lookup[i].sviScore;
                                                wPPLNI = lookup[i].lniScore;
                                                break;
                                                } 
                        }  // end of for loop

                // MemUnlockHandle(lookupTableHandle)
}

Reply via email to