This may be a bug in the OS, I don't know.

Anyways, here is what happened.

I have a form, with a button, which launches the address lookup routines,
returning a string with 4 fields worth of data. So far so good. Then I wanted
to assign to 4 of my fields, so I set the returned string up to contain
markers, which I found, then copied the strings to clipboard, then pasted in my
various fields. And was driven nuts by the famous "This is not permitted...."
error in POSE (linux, 3.03a) with palmos35-Bld20-nonEZDbg.rom on one field. I
checked the code, rewrote probably 15 times, not being a real C whiz. Then I
checked my resource file, pilrc compiled, and found that somehow (!) 
dynamicSize had been set for the one field that had problems. Took that out,
recompiled (gcc) and problem gone away. Works just fine.

Is there a problem pasteing into dynamicsize fields? Shouldn't be.

Here is the code...

void JobEditAssignLookup(VoidHand strh) 
{
        CharPtr resultP;
        CharPtr s;
        Word     bufLen;
        Word textLen;
        Word     end = 0;
        Word companymarker = 0;
        Word namemarker = 0;
        Word phonemarker = 0;
//      Word addressmarker = 0;
        FormPtr frm;
        FieldPtr fld;
                
                resultP = MemHandleLock (strh);
                if (resultP==NULL)
                return;
                bufLen = StrLen(resultP);
                //iterate through string, finding 3 markers.


                for (end=0;end!=bufLen;++end)
                {
                        if (resultP[end] == '*')
                                companymarker = end;
                                
                        if (resultP[end] =='%')
                                namemarker = end;
                                
                        if (resultP[end] == '~')
                                phonemarker = end;
                                
                }
                
        // lookupformatstr   "^company* ^first ^name%^work#^address"
        // sample string in handle "Balfour Superette* %~Box 116"

           frm = FrmGetActiveForm();
       s = resultP;
                        
                fld = FrmGetObjectPtr(frm,FrmGetObjectIndex(frm,customername));
                textLen = FldGetTextLength (fld);
                if (textLen > 0)
                FldSetSelection(fld,0,textLen);
                ClipboardAddItem(clipboardText,resultP,companymarker);
                FldPaste(fld);

       s += companymarker+1;

       fld = FrmGetObjectPtr(frm,FrmGetObjectIndex(frm,contact));
       textLen = FldGetTextLength (fld);
                if (textLen > 0)
                FldSetSelection(fld,0,textLen);
                ClipboardAddItem(clipboardText,s,namemarker-companymarker-1);
                FldPaste(fld);
       s += namemarker-companymarker;

       fld = FrmGetObjectPtr(frm,FrmGetObjectIndex(frm,phone));
       textLen = FldGetTextLength (fld);
                if (textLen > 0)
                FldSetSelection(fld,0,textLen);
                ClipboardAddItem(clipboardText,s,phonemarker-namemarker-1);
                FldPaste(fld);
       s += phonemarker - namemarker;

       fld = FrmGetObjectPtr(frm,FrmGetObjectIndex(frm,address));
       textLen = FldGetTextLength (fld);
                if (textLen > 0)
                FldSetSelection(fld,0,textLen);
       bufLen = StrLen(s);
      ClipboardAddItem(clipboardText,s,bufLen);
                FldPaste(fld);     // error would occur here
                
                MemHandleFree(strh);
}

Here is part of the resource file. 

      FIELD ID customername AT (45 20 110 11) USABLE LEFTALIGN FONT 0 EDITABLE 
UNDERLINED SINGLELINE MAXCHARS 255 AUTOSHIFT 
      FIELD ID jobname AT (45 50 110 11) USABLE LEFTALIGN FONT 0 EDITABLE UNDERLINED 
SINGLELINE MAXCHARS 255 AUTOSHIFT 
      FIELD ID contact AT (45 65 110 11) USABLE LEFTALIGN FONT 0 EDITABLE UNDERLINED 
SINGLELINE MAXCHARS 255 AUTOSHIFT 
      FIELD ID phone AT (45 80 110 11) USABLE LEFTALIGN FONT 0 EDITABLE UNDERLINED 
SINGLELINE MAXCHARS 255 AUTOSHIFT 
      FIELD ID address AT (45 35 110 11) USABLE LEFTALIGN FONT 0 EDITABLE UNDERLINED 
SINGLELINE MAXCHARS 255 AUTOSHIFT

The last one had DYNAMICSIZE.

It works now, just wondering...

Derek

Reply via email to