Brian Stevens wrote: > My code now uses appearance buttons of the > _kControlEditUnicodeTextProc variety and now I need the > functionality of READ FIELD/WRITE FIELD/GET FIELD with this control- > based button. It appears from my rudimentary testing that these > statements don't work with control-based edit fields but only when > they are created via EDIT FIELD...... I'm reading a data file where > each unique record has a variable-sized data component. It could be > 20 characters, 50,000 characters or whatever. READ FIELD/WRITE > field is perfect for this because it writes a 4 byte (ZTXT) header > with the size. My fallback is to just get the handlesize to the > variable portion and write the size out myself using WRITE FILE > followed by the variable-sized data. I'm hoping someone has a more > elegant/better/simpler solution for use with control-based edit > fields. > You need a small suite of functions like those listed below. They should work for _kControlEditTextProc and _kControlEditUnicodeTextProc buttons, and for HITextViews (only in OS X 10.4). Caution: I haven't got around to testing these routines yet. // myTextPtr = fn GetBtnTextAsPtr( txtBtnNum ) replaces get field ztxtHandle, efID local mode local fn GetBtnTextAsPtr( txtBtnNum as long ) '~'1 dim as long @ size dim as Ptr p size = fn ButtonDataSize( txtBtnNum, _kControlEditTextPart, _kControlEditTextTextTag ) p = fn NewPtr( size ) def GetButtonData( txtBtnNum, _kControlEditTextPart, _kControlEditTextTextTag, size, #p, #0 ) end fn = p // caller must DisposePtr // fn WritePtrToFile( fileID, myTextPtr ) replaces write field fileID, ztxtHandle local mode local fn WritePtrToFile( fileID as long, p as Ptr ) '~'1 dim as long @ size size = fn GetPtrSize( p ) write fileID, size // write size write file fileID, p, size // write text data from buffer end fn // myTextPtr = fn ReadPtrFromFile( fileID ) replaces read field fileID, ztxtHandle local mode local fn ReadPtrFromFile( fileID as long ) '~'1 dim as long @ size dim as Ptr p read# fileNum, size // read size p = fn NewPtr( size ) // make buffer read file fileID, p, size // read text data into buffer end fn = p // caller must DisposePtr // fn SetBtnTextFromPtr( txtBtnNum, myTextPtr ) replaces edit$ ( efID ) = &ztxtHandle local mode local fn SetBtnTextFromPtr( txtBtnNum as long, p as Ptr ) '~'1 def SetButtonData( txtBtnNum, _kControlEditTextPart, _kControlEditTextTextTag, fn GetPtrSize( p ), #p ) end fn /* Remember to call DisposePtr( myTextPtr ) when you have finished with the pointer block */ Robert P.