+ Many changes for 2.0 beta

This commit is contained in:
michael 2003-11-16 00:03:03 +00:00
parent 4ff69f3905
commit aff36eb5d0
17 changed files with 423 additions and 137 deletions

View File

@ -23,7 +23,7 @@
HOSTOS=$(shell ppc386 -iSO)
# Which docs are made when 'html' is specified
HTML = user units ref prog fpdoc fcl
HTML = user units ref prog fpdoc fcl chart
# Can be 'report','book', 'html', 'hevea', 'ts3' 'ts4'
ifdef USEHEVEA
@ -319,7 +319,8 @@ endif
#####################################################################
# Tex from XML
#####################################################################
FCLOPTS=--package=fcl --descr=classes.xml --input='$(FPCSRCDIR)/rtl/$(HOSTOS)/classes.pp -Fi$(FPCSRCDIR)/rtl/objpas/classes'
FCLOPTS=--package=fcl --descr=classes.xml --input='$(FPCSRCDIR)/fcl/classes/$(HOSTOS)/classes.pp -Fi$(FPCSRCDIR)/fcl/inc -Fi$(FPCSRCDIR)/fcl/classes'
#FCLOPTS=--package=fcl --descr=classes.xml --input='$(FPCSRCDIR)/rtl/$(HOSTOS)/classes.pp -Fi$(FPCSRCDIR)/rtl/objpas/classes'
fcl.inc: classes.xml
$(FPDOC) --output=fcl.inc $(FCLOPTS) --format=latex
@ -342,6 +343,8 @@ fpdoc.dvi: fpdoc.tex includes
fcl.dvi: fcl.tex fcl.inc includes
chart.dvi: chart.tex
units.pdf: units.tex includes $(CHAPTERS)
ref.pdf: ref.tex includes
@ -358,6 +361,8 @@ fpdoc.pdf: fpdoc.tex includes
fcl.pdf: fcl.tex fcl.inc includes
chart.pdf: chart.tex
dvi : $(DVI)
txt : dvi $(TXT)
@ -550,7 +555,10 @@ execute:
#
# $Log$
# Revision 1.23 2003-11-02 00:14:23 marco
# Revision 1.24 2003-11-16 00:03:03 michael
# + Many changes for 2.0 beta
#
# Revision 1.23 2003/11/02 00:14:23 marco
# * fixed classes moving to rtl, and the OS dependancy of the classes unit
# generation.
#

View File

@ -13,6 +13,8 @@ preamble4:
cp preamble.ts4 preamble.inc
%.html: %.tex
rm -f $(basename $<).aux $(basename $<).idx
rm -f $(basename $<).toc $(basename $<).ind
$(LATEX) $<
$(LATEX) $<
$(LATEX) $<
@ -27,5 +29,6 @@ prog: htmlincludes preamble3 prog.html
onechap: htmlincludes preamble3 onechap.html
ref: htmlincludes preamble4 ref.html
fpdoc: htmlincludes preamble3 fpdoc.html
chart: htmlincludes preamble3 chart.html
html: htmlincludes $(HTML)

View File

@ -99,6 +99,18 @@ ifndef DEBUG
endif
touch fpdoc.chk
chart: chart.chk
chart.chk: htex.chk includes
cp -f preamble.html preamble.inc
$(LATEX2HTML) $(LATEX2HTMLOPTS) -split 2 -link 2\
-t "Free Pascal documentation tool manual" chart.htex
-sed -f foot.sed <chart/footnode.html >chart/footnote.html
-mv chart/footnote.html chart/footnode.html
ifndef DEBUG
-rm -f chart/labels.pl chart/internals.pl chart/.*.pag chart/.*.dir
-rm -f chart/images.* chart/*.log chart/WARNINGS
endif
touch chart.chk
html: $(HTML)

88
docs/chart.tex Normal file
View File

@ -0,0 +1,88 @@
\documentclass{article}
\usepackage{a4}
\setlength{\oddsidemargin}{20pt}
\addtolength{\textwidth}{39pt}
\newcommand{\var}[1]{{\texttt #1}}
\usepackage{tabularx}
\begin{document}
\section*{Compiler options and command-line switches}
\subsection*{Local compiler switches}
%\begin{table}
%\caption[b]{Local compiler switches.}
\begin{tabularx}{\textwidth}{lllX}
\textbf{cmd} & \textbf {short} & \textbf {long} & \textbf{explanation }\\ \hline
& \var{\$A} & \var{\$ALIGN} & Align Data.\\
A & & \var{\$ASMMODE} & Select assembler mode. \\
&\var{\$B} & \var{\$BOOLEVAL} & Use complete boolean evaluation. \\
Sa &\var{\$C} & \var{\$ASSERTIONS} & Enable assertion support. \\
d && \var{\$DEFINE} & Define a symbol. \\
&& \var{\$ELSE} & Switch conditional compilation. \\
&& \var{\$ENDIF} & End conditional compilation. \\
&& \var{\$ERROR} & Generate error message. \\
&\var{\$F} & & Use far or near functions. \\
&& \var{\$FATAL} & Generate fatal error message. \\
Sg && \var{\$GOTO} & Support \var{Goto} and \var{Label}. \\
&\var{\$H} & \var{\$LONGSTRINGS} & Use AnsiStrings. \\
&& \var{\$HINT} & Generate hint message. \\
vh && \var{\$HINTS} & Emit hints \\
&& \var{\$IF} & Start conditional compilation. \\
&& \var{\$IFDEF} & Start conditional compilation. \\
&& \var{\$IFNDEF} & Start conditional compilation. \\
&& \var{\$IFOPT} & Start conditional compilation. \\
&& \var{\$INFO} & Generate info message. \\
Si && \var{\$INLINE} & Enable inline code support. \\
Ci &\var{\$I} & \var{\$IOCHECKS} & Include Input/Output checking. \\
&\var{\$I} & \var{\$INCLUDE} & Include file. \\
&\var{\$I} & \var{\$INCLUDE} & Include compiler info. \\
&\var{\$L} & \var{\$LINK} & Link object file. \\
&& \var{\$LINKLIB} & Link to a library. \\
&\var{\$M} & \var{\$TYPEINFO} & Generate Run-Time type information. \\
Sm && \var{\$MACRO} & Enable macro support. \\
&& \var{\$MESSAGE} & Generate info message. \\
&& \var{\$MMX} & Enable Intel MMX support. \\
&& \var{\$NOTE} & Generate note message. \\
vn && \var{\$NOTES} & Emit notes. \\
A && \var{\$OUTPUT\_FORMAT} & Select compiler output format. \\
&\var{\$P} & \var{\$OPENSTRINGS} & Use open strings. \\
&& \var{\$PACKENUM} & Specify minimum enumeration type size. \\
&& \var{\$PACKRECORDS} & Specify Alignment of record elements. \\
Co &\var{\$Q} & \var{\$OVERFLOWCHECKS}& Use overflow checking. \\
Cr &\var{\$R} & \var{\$RANGECHECKS} & Use range checking. \\
&& \var{\$SATURATION} & Enable saturation operations. \\
XX && \var{\$SMARTLINK} & Use smartlinking. \\
St && \var{\$STATIC} & Enable use of \var{Static} keyword. \\
&& \var{\$STOP} & Generate fatal error message. \\
&\var{\$T} & \var{\$TYPEDADDRESS} & Enable typed address operator. \\
u && \var{\$UNDEF} & Undefine a symbol. \\
&\var{\$V} & \var{\$VARSTRINGCHECKS} & Use strict var-string checking. \\
&& \var{\$WAIT} & Wait for enter key press. \\
&& \var{\$WARNING} & Generate warning message. \\
&& \var{\$WARNINGS} & Emit warnings. \\
&\var{\$X} & \var{\$EXTENDEDSYNTAX} & Enable use of extended syntax. \\ \hline
\end{tabularx}
%\end{table}
\subsection*{Global compiler switches}
%\begin{table}
%\caption{Global compiler switches}
\begin{tabularx}{\textwidth}{lllX}
\textbf{cmd} & \textbf {short} & \textbf {long} & \textbf{explanation }\\ \hline
& & \var{\$APPTYPE} & Specify type of application (Win32 only) \\
g& \var{\$D} & \var{\$DEBUGINFO} & Include debugging symbols. \\
& & \var{\$DESCRIPTION} & Not supported. \\
&\var{\$E} & & Enable emulation of coprocessor. \\
& & \var{\$G} & Generate 80286 code. \\
Fi& & \var{\$INCLUDEPATH} & Specify include file search path. \\
&\var{\$L} & \var{\$LOCALSYMBOLS} & Enable local symbol information. \\
Fl& & \var{\$LIBRARYPATH} & Specify library search path. \\
&\var{\$M} & \var{\$MEMORY} & Specify memory sizes. \\
M& & \var{\$MODE} & Specify compiler compatibility mode. \\
& & \var{\$N} & Enable numeric processing. \\
& & \var{\$O} & Enable overlay code generation. \\
Fo& & \var{\$OBJECTPATH} & Specify object file search path. \\
Ct& \var{\$S} & & Use stack checking \\
Fu& & \var{\$UNITPATH} & Specify unit file search path. \\
& \var{\$W} & \var{\$STACKFRAMES} & Generate stackframes. \\
b & \var{\$Y} & \var{\$REFERENCEINFO} & Insert browser information. \\ \hline
\end{tabularx}
%\end{table}
\end{document}

View File

@ -206,7 +206,7 @@
%
% Some versions
%
\newcommand{\fpcversion}{1.0.10}
\newcommand{\fpcversion}{1.9.0}
%
% PDF support
%

View File

@ -9,6 +9,7 @@
<LI> <A HREF="user/user.html">User's guide</A>.
<LI> <A HREF="prog/prog.html">Programmer's guide</A>.
<LI> <A HREF="ref/ref.html">Reference guide</A> for the system unit, and supported Pascal constructs.
<LI> <A HREF="chart/chart.html">Command-line options and switches Reference chart.</A>.
<LI> <A HREF="units/units.html">Standard units reference manual</A>.
<LI> <A HREF="fcl/index.html">Free Component Library reference manual</A>.
<LI> <A HREF="fpdoc/fpdoc.html">Free Pascal documentation tool manual.</A>.

View File

@ -25,6 +25,11 @@
This document describes the \var{GRAPH} unit for Free Pascal, for all
platforms. The unit was first written for \dos by Florian kl\"ampfl, but was
later completely rewritten by Carl-Eric Codere to be completely portable.
The unit is provided for compatibility only: It is recommended to use more
modern graphical systems. The graph unit will allow to recompile old
programs, they will work to some extent, but if the application has
heavy graphical needs, it's recommended to use another set of graphical
routines, suited to the platform the program should work on.
This chapter is divided in 4 sections.
\begin{itemize}
@ -860,9 +865,7 @@ None.
\Declaration
Procedure InitGraph (var GraphDriver,GraphModus : integer;\\
const PathToDriver : string);
\Description
\var{InitGraph} initializes the \var{graph} package.
\var{GraphDriver} has two valid values: \var{GraphDriver=0} which
performs an auto detect and initializes the highest possible mode with the most
@ -873,7 +876,8 @@ from zero
and \var{graphmode} to the mode you wish (VESA modes where 640x480x256
is \var {101h} etc.).
\var{PathToDriver} is only needed, if you use the BGI fonts from
Borland.
Borland. Free Pascal does not offer BGI fonts like Borland, these must be
obtained separately.
\Errors
None.
\SeeAlso
@ -1497,6 +1501,71 @@ In what follows we describe some things that are different on the various
platforms:
\subsection{\dos}
\subsection{\windows}
\subsection{\linux}
VESA modes (i.e., anything but 320x200x256 and 640x480x16) do not work
under most installations of Windows NT, Windows 2000 and Windows XP.
They also do not work for some people under Windows 98 and Windows ME,
depending on their graphics drivers. However, the graph unit cannot
detect this, because no errors are returned from the system.
In such cases, the screen simply turns black, or will show garbage.
Nothing can be done about this, the reason is missing or buggy
support in the graphics drivers of the operating system.
\subsection{\windows}
The windows version of the Graph units is not very performant. It works,
thus allowing to port old TP programs to Windows, but that is all what can
be expected from it. Further, it is windowed only: A separate window is
opened in which the graphics are displayed. This means that the normal
keyboard/mouse handling as provided by the crt and/or keyboard/mouse units
wil not work in the graphical window. If keyboard and mouse input are needed
the winmouse and the wincrt unit should be used instead.
To hide the console window, compile with the
\begin{verbatim}
{$apptype gui}
\end{verbatim}
switch.
Further, the following extra modes are available:
\begin{verbatim}
mLargestWindow16 = $f0;
mLargestWindow256 = $f1;
mLargestWindow32k = $f2;
mLargestWindow64k = $f3;
mLargestWindow16M = $f4;
mMaximizedWindow16 = $f5;
mMaximizedWindow256 = $f6;
mMaximizedWindow32k = $f7;
mMaximizedWindow64k = $f8;
mMaximizedWindow16M = $f9;
\end{verbatim}
\subsection{\linux}
There are several issues on Linux that need to be taken care of:
\begin{enumerate}
\item The Linux version of the \file{Graph} unit uses the \file{libvga}
library. This library works on the console, not under X.
\item If you get an error similar to
\begin{verbatim}
/usr/bin/ld: cannot find -lvga
\end{verbatim}
This can mean one of two things: either libvga is not installed properly, or
the directory where it is installed is not in the linker path. To remedy the
former, you should install both the libvga package and libvga-devel package
(or compile and install from scratch).
To remedy the latter, you should add the path to the compiler command-line
using the \var{-Fl} option.
\item Programs using \file{libvga} need root privileges to run.
You can make them setuid root with the following command:
\begin{verbatim}
chown root.root myprogram
chmod u+s myprogram
\end{verbatim}
The libvga library will give up the root privileges after it is initialized.
\item there is an experimental version of the Graphics library available that
uses GGI to do all the drawing, but it is not well tested. It's called
\file{ggigraph} and is distributed in source form only.
\item Do not use the CRT unit together with the Graph unit: the console may
end up in an unusable state. Instead, the \file{ncurses} unit may function
fine.
\end{enumerate}

View File

@ -35,26 +35,25 @@ Under no circumstances should the two units be used together.
\item The mouse driver does not know when the text screen scrolls. This results
in unerased mouse cursors on the screen when the screen scrolls while the
mouse cursor is visible. The solution is to hide the mouse cursor (using
HideMouse) when you write something to the screen and to show it again
HideMouse) when writing something to the screen and to show it again
afterwards (using ShowMouse).
\item All Functions/Procedures that return and/or accept coordinates of the mouse
cursor, always do so in pixels and zero based (so the upper left corner of
the screen is (0,0)). To get the (column, row) in standard text mode, divide
both x and y by 8 (and add 1 if you want to have it 1 based).
both x and y by 8 (and add 1 if it must be 1 based).
\item The real resolution of graphic modes and the one the mouse driver uses can
differ. For example, mode 13h (320*200 pixels) is handled by the mouse driver
as 640*200, so you will have to multiply the X coordinates you give to the
driver and divide the ones you get from it by 2 in that mode.
as 640*200, so the X coordinates given to the
driver must be multiplied by 2 and divided by 2 when the return from the
driver in that mode.
\item By default the msmouse unit is compiled with the conditional define
MouseCheck. This causes every procedure/function of the unit to check the
MouseFound variable prior to doing anything. Of course this is not necessary,
so if you are sure you are not calling any mouse unit procedures when no
mouse is found, you can recompile the mouse unit without this conditional
define.
\item
You will notice that several procedures/functions have longint sized
parameters while only the lower 16 bits are used. This is because FPC is
a 32 bit compiler and consequently 32 bit parameters result in faster code.
so when proper checking is added to the calling program, this define may be
removed and the unit can be recompiled.
\item Several procedures/functions have longint sized parameters while only
the lower 16 bits are used. This is because FPC is a 32 bit compiler and
consequently 32 bit parameters result in faster code.
\end{itemize}
\section{Constants, types and variables}
The following constants are defined (to be used in e.g. the
@ -80,8 +79,8 @@ Function GetLastButtonPress (Button: Longint; Var x,y:Longint) : Longint;
Stores the position where \var{Button} was last pressed in \var{x} and
\var{y} and returns
the number of times this button has been pressed since the last call to this
function with \var{Button} as parameter. For \var{Button} you can use the
\var{LButton}, \var{RButton} and \var{MButton} constants for resp. the left,
function with \var{Button} as parameter. For \var{Button} the
\var{LButton}, \var{RButton} and \var{MButton} constants can be used for resp. the left,
right and middle button.
With certain mouse drivers, checking the middle button when using a
two-button mouse to gives and clears the stats of the right button.
@ -104,8 +103,8 @@ Function GetLastButtonRelease (Button: Longint; Var x,y:Longint) : Longint;
stores the position where \var{Button} was last released in \var{x} and
\var{y} and returns
the number of times this button has been released since the last call to this
function with \var{Button} as parameter. For button you can use the
\var{LButton}, \var{RButton} and \var{MButton} constants for resp.
function with \var{Button} as parameter. For button the
\var{LButton}, \var{RButton} and \var{MButton} constants can be used for resp.
the left, right and middle button.
With certain mouse drivers, checking the middle button when using a
two-button mouse to gives and clears the stats of the right button.
@ -127,7 +126,7 @@ Procedure GetMouseState (Var x, y, buttons: Longint);
\var{GetMouseState} Returns information on the current mouse position
and which buttons are currently pressed.
\var{x} and \var{y} return the mouse cursor coordinates in pixels.
\var{Buttons} is a bitmask. Check the example program to see how you can get the
\var{Buttons} is a bitmask. Check the example program to see how to get the
necessary information from it.
\Errors
@ -163,10 +162,9 @@ Procedure InitMouse ;
\var{InitMouse}
Initializes the mouse driver sets the variable \var{MouseFound} depending on
whether or not a mouse is found.
This is Automatically called at the start of your program.
You should never have to call it, unless you want to reset everything to
its default values.
whether or not a mouse is found. This is Automatically called at the start of
a program. Normally it should never be called, unless everything should be
reset to its default values.
\Errors
None.
@ -237,8 +235,8 @@ Procedure SetMouseAscii (Ascii: Byte);
sets the \var{Ascii} value of the character that depicts the mouse cursor in
text mode.
The difference between this one and \seep{SetMouseShape}, is that the foreground
and background colors stay the same and that the Ascii code you enter is the
character that you will get on screen; there's no XOR'ing.
and background colors stay the same and that the Ascii code entered is the
character that will get on screen; there's no XOR'ing.
\Errors
None
@ -258,9 +256,9 @@ Procedure SetMouseHideWindow (xmin,ymin,xmax,ymax: Longint);
defines a rectangle on screen with top-left corner at (\var{xmin,ymin}) and
botto-right corner at (\var{xmax,ymax}),which causes the mouse cursor to be
turned off when it is moved into it.
When the mouse is moved into the specified region, it is turned off until you
call \var{ShowMouse} again. However, once you've called \seep{ShowMouse}, you'll have to
call \var{SetMouseHideWindow} again to redefine the hide window...
When the mouse is moved into the specified region, it is turned off until
call \var{ShowMouse} is called again. However, once \seep{ShowMouse} is
called, \var{SetMouseHideWindow} must be called again to redefine the hide window...
This may be annoying, but it's the way it's implemented in the mouse driver.
While \var{xmin, ymin, xmax} and \var{ymax} are Longint parameters,
only the lower 16 bits are used.
@ -323,7 +321,7 @@ Procedure SetMouseSpeed (Horizontal, Vertical: Longint);
\var{SetMouseSpeed} sets the mouse speed in mickeys per 8 pixels.
A mickey is the smallest measurement unit handled by a mouse. With this
procedure you can set how many mickeys the mouse should move to move the
procedure one can set how many mickeys the mouse should move to move the
cursor 8 pixels horizontally of vertically. The default values are 8 for
horizontal and 16 for vertical movement.
While this procedure accepts longint parameters, only the low 16 bits are
@ -407,7 +405,7 @@ Procedure ShowMouse ;
\Description
\var{ShowMouse} makes the mouse cursor visible.
At the start of your progam, the mouse cursor is invisible.
At the start of the program, the mouse cursor is invisible.
\Errors
None.

View File

@ -1281,7 +1281,7 @@ practice to use makefiles and makefile variables.
\subsection{\var{\protect\$W} or \var{\protect\$STACKFRAMES} : Generate stackframes}
The \var{\{\$W\}} switch directove controls the generation of stackframes.
The \var{\{\$W\}} switch directive controls the generation of stackframes.
In the on state, the compiler will generate a
stackframe for every procedure or function.
@ -1673,7 +1673,7 @@ need to compile with the \var{-Sm} command-line switch.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\chapter{Using Assembly language}
\label{ch:AsmLang}
\fpc supports inserting assembler statements in your code. The
\fpc supports inserting assembler statements in between Pascal code. The
mechanism for this is the same as under Turbo Pascal. There are, however
some substantial differences, as will be explained in the following
sections.
@ -5652,6 +5652,8 @@ Limitations section in this guide (\ref{se:ProcessorLimits}).
Here we list the exact effect of the different compiler modes. They can be
set with the \var{\$Mode} switch, or by command line switches.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% FPC mode
\section{FPC mode}
This mode is selected by the \var{{\$MODE FPC}} switch. On the command-line,
this means that you use none of the other compatibility mode switches.
@ -5667,6 +5669,9 @@ parameters when implementing the function or procedure.
\item You can use the cvar type.
\item PChars are converted to strings automatically.
\end{enumerate}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% TP mode
\section{TP mode}
This mode is selected by the \var{{\$MODE TP}} switch. It tries to emulate,
as closely as possible, the behavior of Turbo Pascal 7. On the command-line,
@ -5684,6 +5689,9 @@ parameters when implementing the function or procedure.
\item Nested comments are not allowed.
\item You can not use the cvar type.
\end{enumerate}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Delphi mode.
\section{Delphi mode}
This mode is selected by the \var{{\$MODE DELPHI}} switch. It tries to emulate,
as closely as possible, the behavior of Delphi 4. On the command-line,
@ -5698,7 +5706,12 @@ parameters when implementing the function or procedure.
\item The Objpas unit is loaded right after the \file{system} unit. One of the
consequences of this is that the type \var{Integer} is redefined as
\var{Longint}.
\item Parameters in class methods can have the same names as class
properties (although it is bad programming practice).
\end{enumerate}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% GPC Mode
\section{GPC mode}
This mode is selected by the \var{{\$MODE GPC}} switch. On the command-line,
this mode is selected by the \var{-Sp} switch.
@ -5712,6 +5725,9 @@ parameters when implementing the function or procedure.
\item Nested comments are not allowed.
\item You can not use the cvar type.
\end{enumerate}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Objfpc mode
\section{OBJFPC mode}
This mode is selected by the \var{{\$MODE OBJFPC}} switch. On the command-line,
this mode is selected by the \var{-S2} switch.
@ -5727,6 +5743,8 @@ consequences of this is that the type \var{Integer} is redefined as
\var{Longint}.
\item You can use the cvar type.
\item PChars are converted to strings automatically.
\item Parameters in class methods cannot have the same names as class
properties.
\end{enumerate}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

View File

@ -441,6 +441,9 @@ in a compiler error:
s := 'some other string';
\end{verbatim}
Prior to version 1.9, \fpc did not correctly support 64-bit constants. As
of version 1.9, 64-bits constants can be specified.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Typed constants
\section{Typed constants}
@ -951,6 +954,26 @@ It is therefore NOT advisable to typecast one of the following:
(call uniquestring to ensure a string has reference count 1)
\end{enumerate}
\subsection{WideStrings}
Widestrings (used to represent unicode character strings) are implemented in much
the same way as ansistrings: reference counted, null-terminated arrays, only they
are implemented as arrays of \var{WideChars} instead of regular \var{Chars}.
A \var{WideChar} is a two-byte character (an element of a DBCS: Double Byte
Character Set). Mostly the same rules apply for \var{WideStrings} as for
\var{AnsiStrings}. The compiler transparantly converts WideStrings to
AnsiStrings and vice versa.
Similarly to the typecast of an Ansistring to a \var{PChar} null-terminated
array of characters, a WideString can be converted to a \var{PWideChar}
null-terminated array of characters.
Note that the \var{PWideChar} array is terminated by 2 null bytes instead of
1, so a typecast to a pchar is not automatic.
The compiler itself provides no support for any conversion from Unicode to
ansistrings or vice versa; 2 procedural variables are present in the system
unit which can be set to handle the conversion. For more information, see
the system units reference.
% Constant strings
\subsection{Constant strings}
@ -1779,7 +1802,53 @@ begin
Writeln('I : ',I);
end.
\end{verbatim}
The first assignment will work
The first assignment will work, but the second will not, as \var{Something else}
cannot be converted to a valid integer value. An \var{EConvertError} exception
will be the result.
The result of an expression involving a variant will be of type variant again,
but this can be assigned to a variable of a different type - if the result
can be converted to a variable of this type.
Note that expressions involving variants take more time to be evaluated, and
should therefore be used with caution. If a lot of calculations need to be
made, it is best to avoid the use of variants.
\subsection{Variants and interfaces}
\begin{remark}
Dispatch interface support for variants is currently broken in the compiler.
\end{remark}
Variants can contain a reference to an interface - a normal interface
(descending from \var{IInterface}) or a dispatchinterface (descending
from \var{IDispatch}). Variants containing a reference to a dispatch
interface can be used to control the object behind it: the compiler will use
late binding to perform the call to the dispatch interface: there will be no
run-time checking of the function names and parameters or arguments given to
the functions. The result type is also not checked. The compiler will simply
insert code to make the dispatch call and retrieve the result.
This means basically, that you can do the following on Windows:
\begin{verbatim}
Var
W : Variant;
V : String;
begin
W:=CreateOleObject('Word.Application');
V:=W.Application.Version;
Writeln('Installed version of MS Word is : ',V);
end;
\end{verbatim}
The line
\begin{verbatim}
V:=W.Application.Version;
\end{verbatim}
is executed by inserting the necessary code to query the dispatch interface
stored in the variant \var{W}, and execute the call if the needed dispatch
information is found.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Objects
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@ -2187,6 +2256,26 @@ these classes. Fields defined in a \var{published} section must be of class type
Array peroperties cannot be in a \var{published} section.
\end{description}
It is also possible to define class reference types:
\input{syntax/classref.syn}
Class reference types are used to create instances of a certain class, which
is not yet known at compile time, but which is specified at run time.
Essentially, a variable of a class reference type contains a pointer to the
VMT of the speficied class. This can be used to construct an instance of the
class corresponding to the VMT. The following example shows how it works:
\begin{verbatim}
Type
TComponentClass = Class of TComponent;
Function CreateComponent(AClass : TComponentClass; AOwner : TComponent) : TComponent;
begin
// ...
Result:=AClass.Create(AOwner);
// ...
end;
\end{verbatim}
More about instantiating a class can be found in the next section.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Class instantiation
@ -2245,12 +2334,13 @@ virtual was used.
The following code is {\em wrong}:
\begin{verbatim}
Type ObjParent = Class
Procedure MyProc; virtual;
end;
ObjChild = Class(ObjPArent)
Procedure MyProc; virtual;
end;
Type
ObjParent = Class
Procedure MyProc; virtual;
end;
ObjChild = Class(ObjPArent)
Procedure MyProc; virtual;
end;
\end{verbatim}
The compiler will produce a warning:
\begin{verbatim}
@ -2787,7 +2877,7 @@ The function that will get called is the function with a declared parameter
list that matches the actual parameter list. This means that
\begin{enumerate}
\item The number of actual parameters must equal the number of declared
parameters.
parameters (unless default parameter values are used).
\item The types of the parameters must be compatible. For variable
reference parameters, the parameter types must be exactly the same.
\end{enumerate}
@ -3582,6 +3672,11 @@ only in that procedure or function's block.
\input{syntax/params.syn}
Constant parameters and variable parameters can also be \var{untyped}
parameters if they have no type identifier.
As of version 1.1, \fpc supports default values for both constant parameters
and value parameters, but only for simple types. The compiler must be in
\var{OBJFPC} or \var{DELPHI} mode to accept default values.
\subsection{Value parameters}
Value parameters are declared as follows:
\input{syntax/paramval.syn}
@ -3601,6 +3696,31 @@ portability's sake (the Intel version limits this to 64K).
Open arrays can be passed as value parameters. See \sees{openarray} for
more information on using open arrays.
For a parameter of a simple type (i.e. not a structured type), a default
value can be specified. This can be an untyped constant. If the function
call omits the parameter, the default value will be passed on to the
function. For dynamic arrays or other types that can be considered as
equivalent to a pointer, the only possible default value is \var{Nil}.
The following example will print 20 on the screen:
\begin{verbatim}
program testp;
Const
MyConst = 20;
Procedure MyRealFunc(I : Integer = MyConst);
begin
Writeln('Function received : ',I);
end;
begin
MyRealFunc;
end.
\end{verbatim}
\subsection{Variable parameters}
\label{se:varparams}
Variable parameters are declared as follows:
@ -3626,6 +3746,25 @@ File type variables must always be passed as variable parameters.
Open arrays can be passed as variable parameters. See \sees{openarray} for
more information on using open arrays.
Note that default values are not supported for variable parameters. This
would make little sense since it defeats the purpose of being able to pass a
value back to the caller.
\subsection{Out parameters}
\label{se:outparams}
Out parameters (output parameters) are declared as follows:
\input{syntax/paramout.syn}
The purpose of an \var{out} parameter is to pass values back to the calling
routine: The variable is passed by reference. The initial value of the
parameter on function entry is discarded, and should not be used.
If a variable must be used to pass a value to a function and retrieve data
from the function, then a variable parameter must be used. If only a value
must be retrieved, a \var{out} parameter can be used.
Needless to say, default values are not supported for \var{out} parameters.
\subsection{Constant parameters}
In addition to variable parameters and value parameters \fpc also supports
Constant parameters. A constant parameter as can be specified as follows:
@ -3643,6 +3782,8 @@ performance, and still retaining the semantics of passing by value...
Constant parameters can also be untyped. See \sees{varparams} for more
information about untyped parameters.
As for value parameters, constant parameters can get default values.
Open arrays can be passed as constant parameters. See \sees{openarray} for
more information on using open arrays.
\subsection{Open array parameters}
@ -3824,6 +3965,13 @@ functions that have a \var{cdecl} modifier cannot be overloaded.
(Technically, because this modifier prevents the mangling of
the function name by the compiler).
Prior to version 1.9 of the compiler, the overloaded functions needed to be
in the same unit. Now the compiler will continue searching in other units if
it doesn't find a matching version of an overloaded function in one unit.
The compiler accepts the presence of the \var{overload} modifier as in
Delphi, but it is not required, unless in Delphi mode.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% forward defined functions
\section{Forward defined functions}

View File

@ -1,12 +1,19 @@
\begin{psyntax}{Constant parameters}{constparameters}
\synt{constant\ parameter}
\lit*{const} \synt{identifier\ list}
\lit*{const}
\begin{stack}
\synt{identifier\ list}
\begin{stack}\\
\lit* :
\begin{stack}\\
\begin{stack}
\\
\lit*{array}
\lit*{of}
\end{stack}
\synt{parameter\ type}
\end{stack}
\\
\synt{identifier} \lit*: \synt{parameter\ type}
\lit*= \synt{default\ parameter\ value}
\end{stack}
\end{psyntax}

12
docs/syntax/paramout.syn Normal file
View File

@ -0,0 +1,12 @@
\begin{psyntax}{Out parameters}{outparameters}
\synt{out\ parameter}
\lit*{out} \synt{identifier\ list}
\begin{stack}\\
\lit* :{}
\begin{stack}\\
\lit*{array}
\lit*{of}
\end{stack}
\synt{parameter\ type}
\end{stack}
\end{psyntax}

View File

@ -6,9 +6,9 @@
\begin{mysyntdiag}
\synt{parameter\ declaration}
\begin{stack}
\synt{value\ parameter}\\
\synt{variable\ parameter}\\
\synt{constant\ parameter}
\synt{value\ parameter} \\
\synt{constant\ parameter} \\
\synt{variable\ parameter}
\end{stack}
\end{mysyntdiag}
\end{diagram}

View File

@ -1,6 +1,11 @@
\begin{psyntax}{Value parameters}{valueparameters}
\synt{value\ parameter}
\begin{stack}
\synt{identifier\ list} \lit*:
\begin{stack}\\ \lit*{array} \lit*{of} \end{stack}
\synt{parameter\ type}
\\
\synt{identifier} \lit*: \synt{parameter\ type}
\lit*= \synt{default\ parameter\ value}
\end{stack}
\end{psyntax}

View File

@ -1117,6 +1117,7 @@ Function ExpandUNCFileName(Const FileName : string): String;
\var{ExpandUNCFileName} runs \seef{ExpandFileName} on \var{FileName}
and then attempts to replace the driveletter by the name of a shared disk.
\Errors
None.
\SeeAlso
\seef{ExtractFileName}, \seef{ExtractFilePath}, \seef{ExtractFileDir},
\seef{ExtractFileDrive}, \seef{ExtractFileExt}, \seef{ExtractRelativePath}

View File

@ -1,85 +0,0 @@
\documentclass{article}
\usepackage{a4}
\setlength{\oddsidemargin}{20pt}
\addtolength{\textwidth}{39pt}
\newcommand{\var}[1]{{\texttt #1}}
\usepackage{tabularx}
\begin{document}
\begin{table}
\caption[b]{Local compiler switches.}
\begin{tabularx}{\textwidth}{llX}
\textbf {short} & \textbf {long} & \textbf{explanation }\\ \hline
\var{\$A} & \var{\$ALIGN} & Align Data.\\
& \var{\$ASMMODE} & Select assembler mode. \\
\var{\$B} & \var{\$BOOLEVAL} & Use complete boolean evaluation. \\
\var{\$C} & \var{\$ASSERTIONS} & Enable assertion support. \\
& \var{\$DEFINE} & Define a symbol. \\
& \var{\$ELSE} & Switch conditional compilation. \\
& \var{\$ENDIF} & End conditional compilation. \\
& \var{\$ERROR} & Generate error message. \\
\var{\$F} & & Use far or near functions. \\
& \var{\$FATAL} & Generate fatal error message. \\
& \var{\$GOTO} & Support \var{Goto} and \var{Label}. \\
\var{\$H} & \var{\$LONGSTRINGS} & Use AnsiStrings. \\
& \var{\$HINT} & Generate hint message. \\
& \var{\$HINTS} & Emit hints \\
& \var{\$IF} & Start conditional compilation. \\
& \var{\$IFDEF} & Start conditional compilation. \\
& \var{\$IFNDEF} & Start conditional compilation. \\
& \var{\$IFOPT} & Start conditional compilation. \\
& \var{\$INFO} & Generate info message. \\
& \var{\$INLINE} & Enable inline code support. \\
\var{\$I} & \var{\$IOCHECKS} & Include Input/Output checking. \\
\var{\$I} & \var{\$INCLUDE} & Include file. \\
\var{\$I} & \var{\$INCLUDE} & Include compiler info. \\
\var{\$L} & \var{\$LINK} & Link object file. \\
& \var{\$LINKLIB} & Link to a library. \\
\var{\$M} & \var{\$TYPEINFO} & Generate Run-Time type information. \\
& \var{\$MACRO} & Enable macro support. \\
& \var{\$MESSAGE} & Generate info message. \\
& \var{\$MMX} & Enable Intel MMX support. \\
& \var{\$NOTE} & Generate note message. \\
& \var{\$NOTES} & Emit notes. \\
& \var{\$OUTPUT\_FORMAT} & Select compiler output format. \\
\var{\$P} & \var{\$OPENSTRINGS} & Use open strings. \\
& \var{\$PACKENUM} & Specify minimum enumeration type size. \\
& \var{\$PACKRECORDS} & Specify Alignment of record elements. \\
\var{\$Q} & \var{\$OVERFLOWCHECKS}& Use overflow checking. \\
\var{\$R} & \var{\$RANGECHECKS} & Use range checking. \\
& \var{\$SATURATION} & Enable saturation operations. \\
& \var{\$SMARTLINK} & Use smartlinking. \\
& \var{\$STATIC} & Enable use of \var{Static} keyword. \\
& \var{\$STOP} & Generate fatal error message. \\
\var{\$T} & \var{\$TYPEDADDRESS} & Enable typed address operator. \\
& \var{\$UNDEF} & Undefine a symbol. \\
\var{\$V} & \var{\$VARSTRINGCHECKS} & Use strict var-string checking. \\
& \var{\$WAIT} & Wait for enter key press. \\
& \var{\$WARNING} & Generate warning message. \\
& \var{\$WARNINGS} & Emit warnings. \\
\var{\$X} & \var{\$EXTENDEDSYNTAX} & Enable use of extended syntax. \\ \hline
\end{tabularx}
\end{table}
\begin{table}
\caption{Global compiler swicthes}
\begin{tabularx}{\textwidth}{llX}
\textbf {short} & \textbf {long} & \textbf{explanation }\\ \hline
& \var{\$APPTYPE} & Specify type of application (Win32 only) \\
\var{\$D} & \var{\$DEBUGINFO} & Include debugging symbols. \\
& \var{\$DESCRIPTION} & Not supported. \\
\var{\$E} & & Enable emulation of coprocessor. \\
& \var{\$G} & Generate 80286 code. \\
& \var{\$INCLUDEPATH} & Specify include file search path. \\
\var{\$L} & \var{\$LOCALSYMBOLS} & Enable local symbol information. \\
& \var{\$LIBRARYPATH} & Specify library search path. \\
\var{\$M} & \var{\$MEMORY} & Specify memory sizes. \\
& \var{\$MODE} & Specify compiler compatibility mode. \\
& \var{\$N} & Enable numeric processing. \\
& \var{\$O} & Enable overlay code generation. \\
& \var{\$OBJECTPATH} & Specify object file search path. \\
\var{\$S} & & Use stack checking \\
& \var{\$UNITPATH} & Specify unit file search path. \\
\var{\$W} & \var{\$STACKFRAMES} & Generate stackframes. \\
\var{\$Y} & \var{\$REFERENCEINFO} & Insert browser information. \\ \hline
\end{tabularx}
\end{table}
\end{document}

View File

@ -1498,7 +1498,8 @@ you want to compile Turbo Pascal code that uses these words.
because \fpc is a 32 bit compiler, so they're obsolete.
\item \var{INTERRUPT} will work only on the \dos target.
\item Boolean expressions are only evaluated until their result is completely
determined. The rest of the expression will be ignored.
determined. The rest of the expression will be ignored. This is
configurable as of FPC 1.9.
\item By default the compiler uses \var{AT\&T} assembler syntax.
This is mainly because \fpc uses \gnu \var{as}. However, other assembler
forms are available. For more information, see \progref.