You're not the only one who is trying to get a grasp on this.
I have a similar problem. I believe the answer to yours is:
You need to lock the field handle down first, then get the text ptr
and then copy it, finally unlocking.
ie:
VoidHand h = FldGetTextHandle((FieldPtr) FrmGetObjectPtr( frm,
FrmGetObjectIndex( frm, PasswordNameField)));
fldText = (CharPtr)MemHandleLock(h);
if (!fldText) goto DoDialog; // wow, a goto! My Comp.Sci threw a
duster at us for doing that
StrToLower(fldText, fldText); // I didn't know you could do this,
but that doesn't say much
... // whatever code is necessary
MemHandleUnlock(h);
Hope that helps. Let me know if I'm wrong!
> -----Original Message-----
> From: Alan Pinstein [SMTP:[EMAIL PROTECTED]]
> Sent: Thursday, June 17, 1999 5:20 PM
> To: [EMAIL PROTECTED]
> Subject: PwdVerify() giving a 'reading from unalloc. chunk' error in
> POSER
>
> [no ideas? anyone? bueller? bueller?... gremlins is complaining!
> thanks for any thoughts]
>
> Hi all-
> I am going nuts here trying to figure out why POSE is complaing about
> reading directly from an unallocated chunk of memory in this routine:
>
> static Boolean GetPassword()
> {
> FormPtr frm;
> CharPtr fldText;
>
> // if no password exists we don't even need to ask...
> if (!PwdExists())
> return true;
>
> frm = FrmInitForm(PasswordForm);
> FrmSetFocus(frm, FrmGetObjectIndex(frm, PasswordNameField));
>
> DoDialog:
>
> if (FrmDoDialog(frm) == PasswordCancelButton) {
> FrmDeleteForm(frm);
> return false;
> }
>
> fldText = (CharPtr)FldGetTextPtr((FieldPtr)FrmGetObjectPtr(frm,
> FrmGetObjectIndex(frm, PasswordNameField)));
>
> if (!fldText)
> goto DoDialog;
>
> StrToLower(fldText, fldText);
>
> if ( PwdExists() && !PwdVerify(fldText) ) { // *** crashing
> here in a MemMove in PwdVerify() ***
> FrmAlert(BadPasswordAlert);
> goto DoDialog;
> }
>
> FrmDeleteForm(frm);
>
> return true;
> }
>
> I've put a breakpoint in before the error and checked in the console to
> make sure that there is an allocated chunk in fldText, which theere is.
> I've also checked to make sure that it's not corrupted, and it isn't...
>
> I think I'm doing everything cleanly, but I must not be, unless there is a
> bug within PwdVerify(). I've tried it on everything from OS 2 to OS 3.1.
>
> Thanks for any help!
>
>
> Alan Pinstein
> Synergy Solutions, Inc.
> http://www.synsolutions.com
> 1-800-210-5293