Show: Object Pascal C++
Display Preferences

System.SysUtils.TryStrToUInt64

From Appmethod Libraries
Jump to: navigation, search

Object Pascal

function TryStrToUInt64(const S: string; out Value: UInt64): Boolean;

C++

extern DELPHI_PACKAGE bool __fastcall TryStrToUInt64(const System::UnicodeString S, /* out */ unsigned __int64 &Value)/* overload */;

Properties

Type Visibility Source Unit Parent
function public
System.SysUtils.pas
System.SysUtils.hpp
System.SysUtils System.SysUtils

Description

Converts a string that represents an integer (decimal or hex notation) into a number.

TryStrToUInt64 converts the string S, which represents an integer-type number in either decimal or hexadecimal notation, into a number, which is assigned to Value. Value is expressed as an unsigned 64 bit sized integer. If S does not represent a valid number, TryStrToUInt64 returns False; otherwise TryStrToUInt64 returns True.

TryStrToUInt64 supports strings in the following hexadecimal notations:

  • Object Pascal: 0$1234 and 0x1234.
  • C++: 0x1234.

To accept decimal but not hexadecimal values in the input string, you may use code like this:

Object Pascal:

function TryDecimalStrToUInt64( const S: string; out Value: UInt64): Boolean;
begin
  result := (pos('$',S)=0) and ((pos('x',S)=0)) and TryStrToUInt64(S,Value);
end;

C++:

bool __fastcall TForm1::TryDecimalStrToUInt64(const System::UnicodeString S, unsigned __int64 &Value)
{
  bool result;
  result= (Pos('x',S)==0) && TryStrToUInt64(S,Value);
  return result;
}

See Also

Personal tools
Translations