Hello:

I have two functions that are exactly the same but I'm having problems
with one of them. The only difference between the functions are the
name of the files.

I'm getting a "Text block size smaller than text" error here and I
can't figure out why.

void LoadFile()
{
Char *name="Error_NQCA";
Err supEr;
FileHand stream=FileOpen(0,name,'ERRO',
appFileCreator,fileModeReadOnly, &supEr);
FileSeek(stream,0,fileOriginBeginning); //lee solo un FIELD por ahora

FieldType* field= GetObjectPtr<FieldType>(MainTextoField);
   UInt16 maxChar=FldGetMaxChars(field);
   Char *textoF=(Char*) MemPtrNew(maxChar*sizeof(Char));

MemHandle old = FldGetTextHandle(field);
UInt32 cantidad=FileRead(stream,textoF,sizeof(Char),maxChar,NULL);
/*this works find when I debug:
                cantidad=177 and textoF has the text I want */

   if(cantidad<=0 || *textoF=='\0')
   {
FldDelete(field,0,maxFieldTextLen); 
}
else
{

MemHandle txtH=MemHandleNew(cantidad*sizeof(Char));
Char* textPtr= (Char*) MemHandleLock(txtH);
StrCopy(textPtr,textoF);
                //textPtr has te same text as textoF when I debug
   MemHandleUnlock(txtH);

FldSetTextHandle(field, txtH); //here I get the problem
FldDrawField(field); 

if (old!= NULL)  
  MemHandleFree(old); 
}

MemPtrFree(textoF);
FileClose(stream);
                 ScrollBarType* scroll=
GetObjectPtr<ScrollBarType>(MainScrollBar);
updateScrollSize(field,scroll);
}

-- 
For information on using the PalmSource Developer Forums, or to unsubscribe, 
please see http://www.palmos.com/dev/support/forums/

Reply via email to