Hi Kristopher,
I have a guess but I could not find any document to support my theory. I
think what is happening is that you cannot guarantee that the FormPtr or any
related with the form will be in the same memory address. The memory
manager is constantly re-arranging memory chunks and I think this is
happening with FormPtr. And I think that is the reason that always when you
manipulate Form you make use of FrmGetActiveForm Function to acquire a valid
FormPtr.
A similar situation happens in Windows programming where you cannot store
Control pointer acquired with (GetDlgItem for example) because that address
is temporary and the system cannot guarantee that will be valid in the
future.
I did not do any testing on this but I think is easy to do it.
* Before instantiating your object call FrmGetActiveForm print the memory
address.
* Create your object. Do stuff ...
* When Accessing the internal FormPtr check again for the FrmGetActiveForm
and compare both.
Please let me know if my guess was true.
Good Luck
ATTACHMATE CORPORATION
Dalmer Azevedo
Mobile Technologies Practice
-----Original Message-----
From: DCU [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, December 29, 1999 8:42 AM
To: [EMAIL PROTECTED]
Subject: Re: class variables
Can you post some example code that demonstrates this?
class Field
{
private:
VoidHand fldHandle;
VoidPtr dataPtr;
FormPtr frmPtr; // buy the time I get to the SetText
function both the frmPtr and
FieldPtr fldPtr; // fldPtr are no longer valid?!?
ULong size;
Word ObjIndex;
public:
void SetText(CharPtr);
Field(FormPtr, Word);
};
Field::Field(FormPtr frmP, Word ID)
{
frmPtr = frmP;
ObjIndex = FrmGetObjectIndex(frmPtr,ID);
fldPtr = (FieldPtr)FrmGetObjectPtr(frmPtr,ObjIndex);
}
void Field::SetText(CharPtr fData)
{
if (FldGetTextPtr(fldPtr))
FldFreeMemory(fldPtr);
size = StrLen(fData) + 1;
fldHandle = MemHandleNew(size);
dataPtr = MemHandleLock(fldHandle);
StrCopy((CharPtr) dataPtr, fData);
MemHandleUnlock(fldHandle);
FldSetTextHandle(fldPtr, (Handle) fldHandle);
}
In this example I am having trouble with the frmPtr and fldPtr varialbles
staying valid.
Please help me if you can,
Kristopher Keller