Logo

Programming-Idioms

History of Idiom 22 > diff from v57 to v58

Edit summary for version 58 by programming-idioms.org:
[Pascal] Less code

Version 57

2016-11-27, 14:44:09

Version 58

2016-11-27, 14:47:52

Idiom #22 Convert string to integer

Extract integer value i from its string representation s (in radix 10)

Illustration

Idiom #22 Convert string to integer

Extract integer value i from its string representation s (in radix 10)

Illustration
Extra Keywords
int base
Extra Keywords
int base
Imports
uses SysUtils;
Imports
uses SysUtils;
Code
var
  i: Integer;
 S: String;
begin
  S := '123';
  i := StrToInt(S);
end.
Code
i := StrToInt(S);
Comments bubble
The function StrToInt will raise an exception of type EConvertError if the string is not a proper representation of an integer.
Comments bubble
The function StrToInt will raise an exception of type EConvertError if the string is not a proper representation of an integer.