TUint GetMyNumberL( const TDesC8& aStringAsNumber) { Â Â TLex8 lexer( aStringAsNumber); Â Â TUint value; Â Â User::LeaveIfError( lexer.Val( value, EDecimal)); Â Â return value; }
void CheckMyImplementationL() { Â Â _LIT8( KAString, "1234abc"); Â Â TBuf8<42> buffer( KAString); Â Â const TUint result = GetMyNumberL( buffer); Â Â _LIT( KPanicCategory, "GetMyNumberL"); Â Â __ASSERT_ALWAYS( result == 1234, User::Panic( KPanicCategory, KErrGeneral)); }
Forum posts: 33
Any suggestions?
Regards, Bo
Forum posts: 3
Can you give me an example?
Forum posts: 33
Can you give me an example?
Try something like this:
{
  TLex8 lexer( aStringAsNumber);
  TUint value;
  User::LeaveIfError( lexer.Val( value, EDecimal));
  return value;
}
void CheckMyImplementationL()
{
  _LIT8( KAString, "1234abc");
  TBuf8<42> buffer( KAString);
  const TUint result = GetMyNumberL( buffer);
  _LIT( KPanicCategory, "GetMyNumberL");
  __ASSERT_ALWAYS( result == 1234, User::Panic( KPanicCategory, KErrGeneral));
}
Regards, Bo
Forum posts: 123
Forum posts: 152
Please check: http://www.symbian.com/developer/techlib/v9.1docs/doc_source/reference/reference-cpp/N101CA/TDes8Class.html#%3a%3aTDes8%3a%3aNum%28%29
Help descriptors!
http://www.tanzim.co.uk/blog/2006/05/29/help-descriptors/
Forum posts: 131
Num() converts integer to string, i.e. exactly the opposite of what the poster wanted...
Forum posts: 135
...
TBuf8 valTBuf;
TInt valInt;
TLex valLex( valTBuf );
valLex.Val( valInt );
// than you will have the number that you have in the TBuf at the TInt
...
## Converte TInt to TBuf ##
...
TInt valInt;
TBuf8 valBuf;
valInt = 123;
valBuf.AppendNum( valInt );
// than you will have the number that you have in the TInt at the TBuf
...
see ya
Developer for PalmOS and Symbian.
by Serginho