Saibamen
Saibamen

Reputation: 648

How to check if there's only numbers in string

how to check if there is only numbers in the string?

I want to skip some code with goto if there's only numbers in the string.

Thanks

Upvotes: 0

Views: 264

Answers (2)

Y.N
Y.N

Reputation: 5257

try
    i := StrToInt( str );
except
    { str is NOT an integer }
end;

Upvotes: 1

NirMH
NirMH

Reputation: 4929

A simple google: Pascal Help

StrToInt

Convert a string to an integer value.

Declaration

Source position: sysstrh.inc line 113

function StrToInt( const s: string ):Integer; Description

StrToInt will convert the string Sto an integer. If the string contains invalid characters or has an invalid format, then an EConvertError is raised.

To be successfully converted, a string can contain a combination of numerical characters, possibly preceded by a minus sign (-). Spaces are not allowed.

The string S can contain a number in decimal, hexadecimal, binary or octal format, as described in the language reference. For enumerated values, the string must be the name of the enumerated value. The name is searched case insensitively.

For hexadecimal values, the prefix '0x' or 'x' (case insensitive) may be used as

Upvotes: 0

Related Questions