mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-12 16:09:25 +02:00
+ support for octal included and Include/Exclude
This commit is contained in:
parent
fcd3bf3b1c
commit
e1031b6b30
96
docs/ref.tex
96
docs/ref.tex
@ -353,15 +353,24 @@ The following diagram gives the basic syntax for identifiers.
|
|||||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
% Numbers
|
% Numbers
|
||||||
\section{Numbers}
|
\section{Numbers}
|
||||||
Numbers are denoted in decimal notation. Real (or decimal) numbers are
|
Numbers are by default denoted in decimal notation.
|
||||||
written using engeneering notation (e.g. \var{0.314E1}).
|
Real (or decimal) numbers are written using engineering or scientific
|
||||||
\fpc supports hexadecimal format the same way as Turbo Pascal does. To
|
notation (e.g. \var{0.314E1}).
|
||||||
specify a constant value in hexadecimal format, prepend it with a dollar
|
|
||||||
|
For integer type constants, \fpc supports 4 formats:
|
||||||
|
\begin{enumerate}
|
||||||
|
\item Normal, decimal format (base 10). This is the standard format.
|
||||||
|
\item Hexadecimal format (base 16), in the same way as Turbo Pascal does.
|
||||||
|
To specify a constant value in hexadecimal format, prepend it with a dollar
|
||||||
sign (\var{\$}). Thus, the hexadecimal \var{\$FF} equals 255 decimal.
|
sign (\var{\$}). Thus, the hexadecimal \var{\$FF} equals 255 decimal.
|
||||||
In addition to the support for hexadecimal notation, \fpc also supports
|
Note that case is insignificant when using hexadecimal constants.
|
||||||
binary notation. A binary number can be specified by preceding it with a
|
\item As of version 1.0.7, Octal format (base 8) is also supported.
|
||||||
percent sign (\var{\%}). Thus, \var{255} can be specified in binary notation
|
To specify a constant in octal format, prepend it with a ampersand (\&).
|
||||||
as \var{\%11111111}.
|
For instance 15 is specified in octal notation as \var{\&17}.
|
||||||
|
\item Binary notation (base 2). A binary number can be specified
|
||||||
|
by preceding it with a percent sign (\var{\%}). Thus, \var{255} can be
|
||||||
|
specified in binary notation as \var{\%11111111}.
|
||||||
|
\end{enumerate}
|
||||||
The following diagrams show the syntax for numbers.
|
The following diagrams show the syntax for numbers.
|
||||||
\input{syntax/numbers.syn}
|
\input{syntax/numbers.syn}
|
||||||
|
|
||||||
@ -4941,6 +4950,7 @@ All things connected to string handling.
|
|||||||
\procref{Insert}{Insert one string in another}
|
\procref{Insert}{Insert one string in another}
|
||||||
\funcref{Length}{Return length of string}
|
\funcref{Length}{Return length of string}
|
||||||
\funcref{Lowercase}{Convert string to all-lowercase}
|
\funcref{Lowercase}{Convert string to all-lowercase}
|
||||||
|
\funcref{OctStr}{Construct octal representation of integer}
|
||||||
\funcref{Pos}{Calculate position of one string in another}
|
\funcref{Pos}{Calculate position of one string in another}
|
||||||
\procref{SetLength}{Set length of a string}
|
\procref{SetLength}{Set length of a string}
|
||||||
\procref{Str}{Convert number to string representation}
|
\procref{Str}{Convert number to string representation}
|
||||||
@ -5096,7 +5106,7 @@ bits are needed, i.e. \var{cnt=32}
|
|||||||
\Errors
|
\Errors
|
||||||
None.
|
None.
|
||||||
\SeeAlso
|
\SeeAlso
|
||||||
\seep{Str},\seep{Val},\seef{HexStr}
|
\seep{Str},\seep{Val},\seef{HexStr}, \seef{OctStr}
|
||||||
\end{function}
|
\end{function}
|
||||||
|
|
||||||
\FPCexample{ex82}
|
\FPCexample{ex82}
|
||||||
@ -5531,6 +5541,28 @@ is opened by the program.
|
|||||||
|
|
||||||
\FPCexample{ex20}
|
\FPCexample{ex20}
|
||||||
|
|
||||||
|
\begin{procedure}{Exclude}
|
||||||
|
\Declaration
|
||||||
|
Procedure Exclude (Var S : Any set type; E : Set element);
|
||||||
|
\Description
|
||||||
|
\var{Exclude} removes \var{E} from the set \var{S} if it is
|
||||||
|
included inthe set. E should be of the same type as the base type
|
||||||
|
of the set \var{S}.
|
||||||
|
|
||||||
|
Thus, the two following statements do the same thing:
|
||||||
|
\begin{verbatim}
|
||||||
|
S:=S-[E];
|
||||||
|
Exclude(S,E);
|
||||||
|
\end{verbatim}
|
||||||
|
\Errors
|
||||||
|
If the type of the element \var{E} is not equal to the base type of the
|
||||||
|
set \var{S}, the compiler will generate an error.
|
||||||
|
\SeeAlso
|
||||||
|
\seep{Include}
|
||||||
|
\end{procedure}
|
||||||
|
|
||||||
|
\FPCexample{ex111}
|
||||||
|
|
||||||
\begin{procedure}{Exit}
|
\begin{procedure}{Exit}
|
||||||
\Declaration
|
\Declaration
|
||||||
Procedure Exit ([Var X : return type )];
|
Procedure Exit ([Var X : return type )];
|
||||||
@ -5771,9 +5803,10 @@ None.
|
|||||||
\begin{function}{HexStr}
|
\begin{function}{HexStr}
|
||||||
\Declaration
|
\Declaration
|
||||||
Function HexStr (Value : longint; cnt : byte) : String;
|
Function HexStr (Value : longint; cnt : byte) : String;
|
||||||
|
Function HexStr (Value : int64; cnt : byte) : String;
|
||||||
\Description
|
\Description
|
||||||
\var{HexStr} returns a string with the hexadecimal representation
|
\var{HexStr} returns a string with the hexadecimal representation
|
||||||
of \var{Value}. The string has at most \var{cnt} charaters.
|
of \var{Value}. The string has exactly \var{cnt} charaters.
|
||||||
(i.e. only the \var{cnt} rightmost nibbles are taken into account)
|
(i.e. only the \var{cnt} rightmost nibbles are taken into account)
|
||||||
To have a complete representation of a Longint-type value, 8
|
To have a complete representation of a Longint-type value, 8
|
||||||
nibbles are needed, i.e. \var{cnt=8}.
|
nibbles are needed, i.e. \var{cnt=8}.
|
||||||
@ -5844,6 +5877,28 @@ error, when an attempt is made to increase \var{X} over its maximum value.
|
|||||||
|
|
||||||
\FPCexample{ex32}
|
\FPCexample{ex32}
|
||||||
|
|
||||||
|
\begin{procedure}{Include}
|
||||||
|
\Declaration
|
||||||
|
Procedure Include (Var S : Any set type; E : Set element);
|
||||||
|
\Description
|
||||||
|
\var{Include} includes \var{E} in the set \var{S} if it is
|
||||||
|
not yet part of the set. E should be of the same type as the base type
|
||||||
|
of the set \var{S}.
|
||||||
|
|
||||||
|
Thus, the two following statements do the same thing:
|
||||||
|
\begin{verbatim}
|
||||||
|
S:=S+[E];
|
||||||
|
Include(S,E);
|
||||||
|
\end{verbatim}
|
||||||
|
\Errors
|
||||||
|
If the type of the element \var{E} is not equal to the base type of the
|
||||||
|
set \var{S}, the compiler will generate an error.
|
||||||
|
\SeeAlso
|
||||||
|
\seep{Exclude}
|
||||||
|
\end{procedure}
|
||||||
|
|
||||||
|
For an example, see \seep{Exclude}
|
||||||
|
|
||||||
\begin{function}{IndexByte}
|
\begin{function}{IndexByte}
|
||||||
\Declaration
|
\Declaration
|
||||||
function IndexByte(var buf;len:longint;b:byte):longint;
|
function IndexByte(var buf;len:longint;b:byte):longint;
|
||||||
@ -6247,6 +6302,21 @@ None.
|
|||||||
|
|
||||||
\FPCexample{ex43}
|
\FPCexample{ex43}
|
||||||
|
|
||||||
|
\begin{function}{OctStr}
|
||||||
|
\Declaration
|
||||||
|
Function OctStr (Value : longint; cnt : byte) : String;
|
||||||
|
Function OctStr (Value : int64; cnt : byte) : String;
|
||||||
|
\Description
|
||||||
|
\var{OctStr} returns a string with the octal representation
|
||||||
|
of \var{Value}. The string has exactly \var{cnt} charaters.
|
||||||
|
\Errors
|
||||||
|
None.
|
||||||
|
\SeeAlso
|
||||||
|
\seep{Str}, \seep{Val}, \seef{BinStr}, \seef{HexStr}
|
||||||
|
\end{function}
|
||||||
|
|
||||||
|
\FPCexample{ex112}
|
||||||
|
|
||||||
\begin{function}{Ofs}
|
\begin{function}{Ofs}
|
||||||
\Declaration
|
\Declaration
|
||||||
Function Ofs (Var X) : Longint;
|
Function Ofs (Var X) : Longint;
|
||||||
@ -7010,7 +7080,11 @@ value, and stores this value in the variable \var{V}, which
|
|||||||
can be of type \var{Longint}, \var{Real} and \var{Byte}.
|
can be of type \var{Longint}, \var{Real} and \var{Byte}.
|
||||||
If the conversion isn't succesfull, then the parameter \var{Code} contains
|
If the conversion isn't succesfull, then the parameter \var{Code} contains
|
||||||
the index of the character in \var{S} which prevented the conversion.
|
the index of the character in \var{S} which prevented the conversion.
|
||||||
The string \var{S} isn't allowed to contain spaces.
|
The string \var{S} is allowed to contain spaces in the beginning.
|
||||||
|
|
||||||
|
The string \var{S} can contain a number in decimal, hexadecimal, binary
|
||||||
|
or octal format, as described in the language reference.
|
||||||
|
|
||||||
\Errors
|
\Errors
|
||||||
If the conversion doesn't succeed, the value of \var{Code} indicates the
|
If the conversion doesn't succeed, the value of \var{Code} indicates the
|
||||||
position where the conversion went wrong.
|
position where the conversion went wrong.
|
||||||
|
Loading…
Reference in New Issue
Block a user