--- ../gcc-3.2.1/gcc/p.dist/doc/en/reference.texi 2003-05-03 18:33:37.000000000 +0200 +++ ../gcc-3.2.1/gcc/p/doc/en/reference.texi 2003-08-16 12:06:59.000000000 +0200 @@ -5851,6 +5851,108 @@ @ref{Integer Types}, @ref{Subrange Types}. +@c ---------------------------------------------------------------------------- + +@node Integer2StringBase +@unnumberedsec Integer2StringBase +@cindex Integer2StringBase + +(Under construction.) + +@subheading Synopsis + +@example +type TConversionBase = 2..36; + +function Integer2StringBase (SourceInt: LongInt; Base: TConversionBase): TString; +@end example + +@subheading Description + +@samp{Integer2StringBase} returns number @samp{SourceInt} converted to +string representation in base @samp{Base}. Base can be 2 to 36, and source +number can be negative, in which case the number is converted in +representation with a sign, not a 2's complement or similar. + +The string is not prefixed with a base prefix - if you need that representation +you can use @samp{Integer2StringBaseExt}. + +@subheading Conforming to + +@samp{Integer2StringBase} is a GNU Pascal extension. + +@subheading Example + +@example +program int2strb; +uses GPC; +var s : String; +begin + s := Integer2StringBase (42, 2); { s := '101010'; } + s := Integer2StringBase (-42, 8); { s := '-52'; } +end. +@end example + +@subheading See also + +@ref{Integer2StringBaseExt}, @ref{ReadStr}, @ref{Val}, @ref{Str},@ref{WriteStr}. + +@c ---------------------------------------------------------------------------- + +@node Integer2StringBaseExt +@unnumberedsec Integer2StringBaseExt +@cindex Integer2StringBaseExt + +(Under construction.) + +@subheading Synopsis + +@example +type TConversionBase = 2..36; + TConversionWidth = 0..High(TString); + +function Integer2StringBase (SourceInt: LongInt; + Base: TConversionBase; Width: TConversionWidth; + UpperCase: Boolean; AddBasePrefix: Boolen): TString; +@end example + +@subheading Description + +@samp{Integer2StringBaseExt} returns number @samp{SourceInt} converted to +string representation in base @samp{Base}. Base can be 2 to 36, and source +number can be negative, in which case the number is converted in +representation with a sign, not a 2's complement or similar. + +The String is optionally prefixed with zero digits to have @samp{Width} digits +together with optional base prefix if @samp{AddbasePrefix} is set to @samp{True}. +The digits are in range 0..Base-1, while digits with value higher than 9 are +represented by lowercase letters 'a' to 'z', similar to 'a' .. 'f' in hexadecimal +notation (or uppercase letters if @samp{UpperCase} is set to @samp{True}). + +String resulting from number conversion is always at least @samp{Width} characters +long. If you don't want zero padding, supply @samp{0} as @samp{Width} parameter. + +@subheading Conforming to + +@samp{Integer2StringBaseExt} is a GNU Pascal extension. + +@subheading Example + +@example +program int2strb; +uses GPC; +var s : String; +begin + s := Integer2StringBaseExt (42, 2, 8, False, True); { s := '2#00101010'; } + s := Integer2StringBaseExt (-42, 8, 0, False, True); { s := '-8#52'; } + s := Integer2StringBaseExt (3280362042165575, 36, 0, True, Fakse); + { s := 'Washington'; } +end. +@end example + +@subheading See also + +@ref{Integer2StringBase}, @ref{ReadStr}, @ref{Val}, @ref{Str},@ref{WriteStr}. @c ---------------------------------------------------------------------------- @@ -12413,14 +12515,46 @@ @subheading Description +@samp{Val} converts the integer or real number that is represented by +characters in string @samp{Source} and places it into @samp{x}. + +@samp{Source} string can have a base prefix. Optional @samp{ErrorCode} +will be set to the position of the first character illegal for the range +of valid digits for the given conversion base, or to a 0 if entire string +represents a valid number. In case illegal character occured in +@samp{Source}, @samp{x} will be undefined. + @subheading Conforming to @samp{Val} is a Borland Pascal extension. @subheading Example +@example +program ValTest; +var x, ec: Integer; + l : LongInt; + r : Real; + +begin + Val ('123', x); { x := 123; } + Val ('-123', x); { x := -123; } + Val ('123.456', r); { r := 123.456; } + Val ('$ffff', x); { x := 65535; } + Val ('$F000', x); { x := 61440; } + Val ('-$ffff', x); { x := -65535; } + Val ('12#100', x, ec); { x := 144; ec := 0; } + Val ('-2#11111111', x, ec); { x := -255; ec := 0; } + { here we have invalid character 'X' for base 16 } + Val ('$fffeX', x, ec); { x := ; ec := 6; } + Val ('12#100invalid', x, ec); { x := ; ec := 7; } + Val ('36#Jerusalem', l, ec); { l := 54758821170910; ec := 0; } +end. +@end example + @subheading See also +@ref{ReadLn}, @ref{ReadStr}, @ref{WriteLn}, @ref{WriteStr}, @ref{Str}. @c ----------------------------------------------------------------------------