> Actually, it looks kind of like you might be deleting a locked
> handle somewhere, as you thought.  Also, try changing the incrementation
> of your counters in your loop to j++ and i++.  Just a thought...

Thanks for the suggestions, but the post increment didn't help.  I didn't
figure it would in that case, but it never hurts :-)

The only other place where I access these handles are in my LoadData and
SaveData Procedures.  Here is an example of two of them, and they seem to be
look right.  In fact, I don't run into any Gremlins problems.  However, when
I exit my app, I'm not sure if those global handles are freed.  I doubt it.

Feel free to look if you wish :-)  Any suggestions would be VERY much
appreciated.



static Err DisSelectLoadDataJurisdictionField(VoidPtr table, Word row, Word
column, Boolean editable, VoidHand *dataH, WordPtr dataOffset, WordPtr
dataSize, FieldPtr fld)
{
 tblDist theDist;
 tblPackedDistPtr p;
 FieldAttrType fldAttr;
 VoidHand record;
 UInt index;
 Char defaultJurisdiction[] = "EMPTY";

 // Set Field Attributes
 FldGetAttributes(fld, &fldAttr);
 fldAttr.usable   = true;
 fldAttr.visible   = true;
 fldAttr.editable  = true;
 fldAttr.singleLine  = true;
 fldAttr.dynamicSize  = false;
 fldAttr.underlined  = true;
 fldAttr.insPtVisible = true;
 fldAttr.numeric   = false;
 fldAttr.justification = leftAlign;
 fldAttr.autoShift  = true;
 FldSetAttributes(fld, &fldAttr);

 // Set the Maximum Character Length for the field
 FldSetMaxChars(fld, JURISDICTION_LENGTH);

 // Get index
 index = TblGetRowID(table, row);

 // Query Record
 record = DmQueryRecord(gDistDB, index);

 // Lock the Record and unpack it
 p = MemHandleLock(record);
 UnpackDist(&theDist, p);

 // Unlock the record
 MemHandleUnlock(record);

 // If a handle exists, free it
 if(DisTableHandles[column][row])
  MemHandleFree(DisTableHandles[column][row]);

 // Copy the data to the handle
 if(StrCompare(theDist.Jurisdiction, "") == 0)
 {
  DisTableHandles[column][row] = MemHandleNew(StrLen(defaultJurisdiction) +
1);
  StrCopy(MemHandleLock(DisTableHandles[column][row]), defaultJurisdiction);
 }
 else
 {
  DisTableHandles[column][row] = MemHandleNew(StrLen(theDist.Jurisdiction) +
1);
  StrCopy(MemHandleLock(DisTableHandles[column][row]), theDist.
Jurisdiction);
 }
 MemHandleUnlock(DisTableHandles[column][row]);

 // Set the field data
 *dataH = DisTableHandles[column][row];
 *dataOffset = 0;
 *dataSize = MemHandleSize(*dataH);

 return(0);
}





static Boolean DisSelectSaveDataJurisdictionField(VoidPtr table, Word row,
Word column)
{
 tblDist theDist;
 tblPackedDistPtr p;
 FieldPtr fld;
 VoidHand record;
 UInt curSize, newSize;
 UInt index;
 Boolean handled = false;

 fld = TblGetCurrentField(table);

 if(fld && FldDirty(fld))


  // Compact Text
  FldCompactText(fld);

  // Get index
  index = TblGetRowID(table, row);

  // Get Record
  record = DmGetRecord(gDistDB, index);

  // Lock Record
  p = MemHandleLock(record);

  // Unpack Record
  curSize = MemPtrSize(p);
  UnpackDist(&theDist, p);
  newSize = curSize;

  // Calculate size
  newSize += StrLen(FldGetTextPtr(fld)) - StrLen(theDist.Jurisdiction);

  // If the new size is larger than the existing size
  if(newSize > curSize)
  {
   // Enlarge the record accordingly
   MemPtrUnlock(p);
   MemHandleResize(record, newSize);
   p = MemHandleLock(record);
   UnpackDist(&theDist, p);
  }

  // Set the Field to the correct field in the Record
  DisChangeRecordField(p, curSize, FldGetTextPtr(fld),
theDist.Jurisdiction);

  // If the new size is less than the existing size
  if(newSize < curSize)
   MemPtrResize(p, newSize);

  MemPtrUnlock(p);

  // Remove busy bit, set dirty bit
  DmReleaseRecord(gDistDB, index, true);

  handled = true;
 }

 return(handled);
}




Timothy D. Astle

People on Jolt cola write the funniest things.

                                     A-10 Obedience Guide,
                                     Kitty Hawk Studios





-- 
For information on using the ACCESS Developer Forums, or to unsubscribe, please 
see http://www.access-company.com/developers/forums/

Reply via email to