TTxtFile and missing method AppLine

Post Reply
User avatar
jicorral
Posts: 47
Joined: Thu Jul 10, 2008 7:33 am
Contact:

TTxtFile and missing method AppLine

Post by jicorral »

Reviewing the code of TTxtFile.prg I can't find the method AppLine that is used in the inside the code. Neither the class nor the parent, TFile, has this method.

An example:

Code: Select all | Expand

    oFich := TTxtFile():New('texto.txt', FC_NORMAL)    if oFich:Open()        oFich:SetValue('OPTIONS', 'Auto Index', 'Yes')        oFich:End()    endif 


In runtime I get:

   Called from:  => __ERRRT_SBASE(0)
   Called from: source\rtl\tobject.prg => TTXTFILE:ERROR(0)
   Called from: source\rtl\tobject.prg => (b)HBOBJECT(0)
   Called from: source\rtl\tobject.prg => TTXTFILE:MSGNOTFOUND(0)
   Called from: source\rtl\tobject.prg => TTXTFILE:APPLINE(0)
   Called from: .\source\classes\TTxtFile.PRG => TTXTFILE:SETVALUE(279)
Jorge Ignacio Corral
Enjoy it :)
User avatar
jicorral
Posts: 47
Joined: Thu Jul 10, 2008 7:33 am
Contact:

Re: TTxtFile and missing method AppLine

Post by jicorral »

A workarround:

Code: Select all | Expand

__clsAddMsg(TTxtFile():ClassH, 'AppLine', {|o,t| o:AppendLn(t)}, HB_OO_MSG_INLINE,, HB_OO_CLSTP_EXPORTED)


Is there a simpler way to change a class message with other? Something like that:

Code: Select all | Expand

__clsAddMsg(TTxtFile():ClassH, 'AppLine', 'AppendLn', HB_OO_MSG_MESSAGE,, HB_OO_CLSTP_EXPORTED)
Jorge Ignacio Corral
Enjoy it :)
User avatar
ukoenig
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany
Contact:

Re: TTxtFile and missing method AppLine

Post by ukoenig »

Code: Select all | Expand

// oFich:SetValue('OPTIONS', 'Auto Index', 'Yes')FUNCTION TEXTNEW()local aValue := {'OPTIONS', 'Auto Index', 'Yes'}// If You don't delete the file, the next run will add the text// can be used to reccord something to a textfileIF FILE( "texto.txt" )    DELETE FILE  "texto.txt"ENDIFoFich := TTxtFile():New( "texto.txt" )IF oFich:Open()   oFich:Add('OPTIONS')   oFich:Add('Auto Index')   oFich:Add('Yes')    oFich:Add('')  // Append empty line   // You can use the array as well   // i := 1   // For i := 1 To 3   //      oFich:Add( aValue[i] )   // NextENDIFRETURN NIL 


Regards
Uwe :lol:
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
jicorral
Posts: 47
Joined: Thu Jul 10, 2008 7:33 am
Contact:

Re: TTxtFile and missing method AppLine

Post by jicorral »

Uwe,

Thx but that doesn't work. SetValue seek the section (OPTIONS) and add the pair label=value. Anyway, know do it:

Code: Select all | Expand

    oFich := TTxtFile():Create(cDir + cNom + FUEPROYEXT, FC_NORMAL)    if oFich:Open()        if oFich:Seek('[OPTIONS]', SEEK_FORWARD, SEEK_UPCASE)        oFich:AppendLn('Auto Index=Yes')... 


I was only reporting a bug in TTxtFile: The method SetValue use the method AppLine that doesn't exist.

Code: Select all | Expand

METHOD SetValue( cSection, cKeyword, xValue ) CLASS TTxtFile     LOCAL cLine     ::GoTop()     IF !::Seek( "[" + cSection + "]" )          ::AppLine( ""  )          ::AppLine( "[" + cSection + "]"  )          ::AppLine( ckeyword + "=" + cValToChar(xValue) )          RETU NIL     ENDIF     cLine := ::cLine     DO WHILE !::lEof() .AND. !(cLine ="[")          IF cLine = cKeyword               ::RepLine( ckeyword + "=" + cValToChar(xValue) )               RETU NIL          ENDIF          ::Advance()          cLine := ::cLine     ENDDO     IF !::lEof()          ::InsLine( ckeyword + "=" + cValToChar(xValue) )     ELSE          ::AppLine( ckeyword + "=" + cValToChar(xValue) )     ENDIFRETURN NIL 
Jorge Ignacio Corral
Enjoy it :)
Post Reply