Post by berthelot samuelThanks. I wrote the following function and it works. Well it works
without the line temp.Format(String, args) but the point is that I
illegal implicit conversion from 'HBufC16 *' to
'TRefByValue<const TDesC16>'
I don't really understand Symbian String Handling functions ... Does
anyone know how to solve my problem quickly and simply (just a simple
conversion perhaps...?)
I barely get my head around the difference between HBuf, TDes and TPtr
myself! Assuming 'String' in your example below is a formatting string for
the following arguments (in other words, it's a variant of "printf()"),
then I think your problem comes from the fact that your ALSO trying
(through 'temp') to use it as where the output goes...
Instead, you need a 'real' buffer to hold the formatted output. Something
like:
void CLog::WriteToFileL( const TDesC& String, ... )
{
TBuf<255> buffer ;
va_list args ;
va_start( args, String ) ;
buffer.Format( String, args ) ;
va_end( args ) ;
m_file << buffer ;
m_file.CommitL() ;
}
(WARNING: I've only checked that this COMPILES ok; I've not actually tested
it!)
I think "const TDesC&" is the "preferred" way of passing in a 'string' that
isn't going to be modified, as it will accept references to almost all
variants.
You will obviously need to adjust the '255' above to set aside the maximum
number of characters you'll need.
Post by berthelot samuelvoid CLog::WriteToFileL(HBufC* String, ...)
{
TPtr temp = String->Des();
va_list args;
if (String == NULL)
return;
va_start(args, String);
temp.Format(String, args);
va_end(args);
m_file << temp;
m_file.CommitL();
}
Post by Graham HoldenPost by berthelot samuelHi
Has anyone ever written a simple program that just writes data into a
file. I use CEikDocument but all the examples I've found use
CQikDocument and it doesn't appear to be compatible....
Symbian programming is painful :-(
(all from things I've seen, rather than written myself...)
If you just want to read/write to your own files, RFile or TTextFile would
probably do (as far as I can see, RFile is fairly close to a FILE*).
I would guess that the CQik... examples are for Symbian version 6.0, as
opposed to EPOC ER5 for CEik... If you've got the ER5 SDK, then have a
look at the examples in \Epoc32ex\Eikfile.
Regards,
Graham Holden (g-holden AT dircon DOT co DOT uk)
Regards,
Graham Holden (g-holden AT dircon DOT co DOT uk)
--
There are 10 types of people in the world;
those that understand binary and those that don't.