procedure TForm1.W3Button16Click(Sender: TObject);
var
A, B, C, D, E, F : Integer;
str1, str2, str3, str4 : string;
begin
str1 := '100';
str2 := ' -12';
str3 := '$FE' ;
str4 := '-$FE';
A := str1.ToInteger;
//str1.ToIntegerDef(str1);
B := str1.ToIntegerDef(0); // '100' string converted to 100 integer
C := str2.ToIntegerDef(0); // Leading blanks are ignored
D := str3.ToIntegerDef(66); // Hexadecimal values start with a '$'
E := str4.ToIntegerDef(55); // ... or with a '0x'
F := A + B + C + D + E; // Lets add up all these integers
WriteLn('a: '+ IntToStr( '100 '.ToIntegerDef(123)) ); // Trailing blanks are not supported
WriteLn('b: '+ IntToStr( '$FE'.ToIntegerDef(-1)) );
WriteLn('c: '+ IntToStr( '-$FE'.ToIntegerDef(-1)) );
WriteLn('d: '+ IntToStr( '0xFE'.ToIntegerDef(-2)) );
WriteLn('e: '+ IntToStr( '-0xFE'.ToIntegerDef(-2)) );
WriteLn('A : '+IntToStr(A));
WriteLn('B : '+IntToStr(B));
WriteLn('C : '+IntToStr(C));
WriteLn('D : '+IntToStr(D));
WriteLn('E : '+IntToStr(E));
WriteLn('F : '+IntToStr(F));
end;
|