user.tex 92 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343
  1. %
  2. % $Id$
  3. % This file is part of the FPC documentation.
  4. % Copyright (C) 1997, by Michael Van Canneyt
  5. %
  6. % The FPC documentation is free text; you can redistribute it and/or
  7. % modify it under the terms of the GNU Library General Public License as
  8. % published by the Free Software Foundation; either version 2 of the
  9. % License, or (at your option) any later version.
  10. %
  11. % The FPC Documentation is distributed in the hope that it will be useful,
  12. % but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. % Library General Public License for more details.
  15. %
  16. % You should have received a copy of the GNU Library General Public
  17. % License along with the FPC documentation; see the file COPYING.LIB. If not,
  18. % write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  19. % Boston, MA 02111-1307, USA.
  20. %
  21. \documentclass{report}
  22. \usepackage{a4}
  23. \usepackage{html}
  24. \makeindex
  25. \latex{\usepackage{multicol}}
  26. \latex{\usepackage{fpkman}}
  27. \html{\input{fpk-html.tex}}
  28. % define the version number here, and not in the fpk.sty !!!
  29. \newcommand{\fpkversion}{0.9.5}
  30. \newcommand{\remark}[1]{\par$\rightarrow$\textbf{#1}\par}
  31. % define many-used references.
  32. %\newcommand{\progref}{\htmladdnormallink{Programmer's guide}{../prog/prog.html}\ }
  33. %\newcommand{\refref}{\htmladdnormallink{Reference guide}{../ref/ref.html}\ }
  34. %\newcommand{\seecrt}{\htmladdnormallink{CRT}{../crt/crt.html}}
  35. %\newcommand{\seelinux}{\htmladdnormallink{Linux}{../linux/linux.html}}
  36. %\newcommand{\seestrings}{\htmladdnormallink{strings}{../strings/strings.html}}
  37. %\newcommand{\seedos}{\htmladdnormallink{DOS}{../dos/dos.html}}
  38. %\newcommand{\seegetopts}{\htmladdnormallink{getopts}{../getopts/getopts.html}}
  39. %\newcommand{\seeobjects}{\htmladdnormallink{objects}{../objects/objects.html}}
  40. %\newcommand{\seegraph}{\htmladdnormallink{graph}{../graph/graph.html}}
  41. %\newcommand{\seeprinter}{\htmladdnormallink{printer}{../printer/printer.html}}
  42. %\newcommand{\seego}{\htmladdnormallink{GO32}{../go32/go32.html}}
  43. %
  44. \newcommand{\olabel}[1]{\label{option:#1}}
  45. % We should change this to something better. See \seef etc.
  46. \newcommand{\seeo}[1]{See \ref{option:#1}}
  47. \begin{document}
  48. \title{Free Pascal :\\ User's manual}
  49. \docdescription{User's manual for \fpk, version \fpkversion}
  50. \docversion{1.0}
  51. \date{July 1997}
  52. \author{Micha\"el Van Canneyt\\Florian Kl\"ampfl}
  53. \maketitle
  54. \tableofcontents
  55. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  56. % Introduction
  57. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  58. \chapter{Introduction}
  59. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  60. % About this document
  61. \section{About this document}
  62. This is the user's manual for \fpk . It describes the installation and use of
  63. the \fpk compiler on the different supported platforms.
  64. It does not attempt to give an exhaustive list of all supported commands,
  65. nor a definition of the Pascal language. Look at the
  66. \refref for these things.
  67. For a description of the
  68. possibilities and the inner workings of the compiler, see the
  69. \progref. In the appendices of this document you will find lists of
  70. reserved words and compiler error messages (with descriptions).
  71. This document describes the compiler as it is/functions at the time of
  72. writing. Since the compiler is under continuous development, some of the
  73. things described here may be outdated. In case of doubt, consult the
  74. \file{README} files, distributed with the compiler.
  75. The \file{README} files are, in case of conflict with this manual,
  76. authoritative.
  77. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  78. % About the compiler
  79. \section{About the compiler}
  80. \fpk is a 32-bit compiler for the i386 processor\footnote{Work is being done
  81. on a port to ALPHA Architecture}. Currently, it supports 2 operating systems:
  82. \begin{itemize}
  83. \item \dos
  84. \item \linux
  85. \end{itemize}
  86. and work is in progress to port it to other platforms (notably, \ostwo and
  87. \windowsnt).
  88. \fpk is designed to be, as much as possible, source compatible with
  89. Turbo Pascal 7.0 and Delphi II (although this goal is not yet attained),
  90. but it also enhances these languages with elements like function overloading.
  91. And, unlike these ancestors, it supports multiple platforms.
  92. It also differs from them in the sense that you cannot use compiled units
  93. from one system for the other.
  94. Also, at the time of writing, there is no Integrated Development Environment
  95. (IDE) available for \fpk. This gap will, hopefully, be filled in the future.
  96. \fpk consists of three parts :
  97. \begin{enumerate}
  98. \item The compiler program itself.
  99. \item The Run-Time Library (RTL).
  100. \item Utility programs and units.
  101. \end{enumerate}
  102. Of these you only need the first two, in order to be able to use the compiler.
  103. In this document, we describe the use of the compiler. The RTL is described in the
  104. \refref.
  105. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  106. % Getting more information.
  107. \section{Getting more information.}
  108. If the documentation doesn't give an answer to your questions,
  109. you can obtain more information on the Internet, on the following addresses:
  110. \begin{itemize}
  111. \item \htmladdnormallink{http://tfdec1.fys.kuleuven.ac.be/\~ michael/fpk.html}
  112. {http://tfdec1.fys.kuleuven.ac.be/~michael/fpk.html} contains information
  113. on the \linux port of the compiler. It contains also useful mail addresses and
  114. links to other places.
  115. \item \htmladdnormallink{http://www.brain.uni-freiburg.de/\~klaus/fpk-pas}
  116. {http://www.brain.uni-freiburg.de/~klaus/fpk-pas} is the main \fpk information site.
  117. It also contains the instructions for inscribing to the \textit{mailing-list},
  118. another useful source of information.
  119. \end{itemize}
  120. Both places can be used to download the \fpk distribution, although you can
  121. probably find them on other places also.
  122. Finally, if you think something should be added to this manual
  123. (entirely possible), please do not hesitate and contact me at
  124. \htmladdnormallink{[email protected]}{mailto:[email protected]}
  125. .
  126. Let's get on with something useful.
  127. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  128. % Installation
  129. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  130. \chapter{Installing the compiler}
  131. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  132. % Before Installation : Requirements
  133. \section{Before Installation : Requirements}
  134. %
  135. %
  136. % System requirements
  137. \subsection{System requirements}
  138. The compiler needs at least the following hardware:
  139. \begin{enumerate}
  140. \item An I386 or higher processor. A coprocessor is not required, although it
  141. will slow down your program's performance if you do floating point calculations.
  142. \item 4 Mb of free memory. Under \dos, if you use DPMI memory management,
  143. such as under Windows, you will need at least 8 Mb.
  144. \item At least 500 Kb. free disk space.
  145. \end{enumerate}
  146. %
  147. %
  148. % Software requirements
  149. \subsection{Software requirements}
  150. \subsubsection{Under DOS}
  151. The \dos distribution contains all the files you need to run the compiler
  152. and compile pascal programs.
  153. \subsubsection{Under Linux}
  154. Under \linux you need to have the following programs installed :
  155. \begin{enumerate}
  156. \item \gnu \file{as}, the \gnu assembler.
  157. \item \gnu \file{ld}, the \gnu linker.
  158. \item Optionally (but highly recommended) : \gnu \file{make}. For easy
  159. recompiling of the compiler and Run-Time Library, this is needed.
  160. \end{enumerate}
  161. Other than that, \fpk should run on almost any \linux system.
  162. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  163. % Installing the compiler.
  164. \section{Installing the compiler.}
  165. The installation of \fpk is easy, but is platform-dependent.
  166. We discuss the process for each platform separately.
  167. %
  168. %
  169. % Installing under DOS
  170. \subsection{Installing under DOS}
  171. \subsubsection{Mandatory installation steps.}
  172. First, you must get the latest distribution files of \fpk. They come as zip
  173. files, which you must unzip first. The distribution zip file contains an
  174. installation program \file{INSTALL.EXE}. You must run this program to install
  175. the compiler. It allows you to select:
  176. \begin{itemize}
  177. \item What components you wish to install. (e.g do you want the sources or
  178. not, do you want Free Vision etc.)
  179. \item Where you want to install (the default location is \verb|C:\PP|).
  180. \end{itemize}
  181. The installation program generates a batch file which sets some environment
  182. variables : \verb|SET_PP.BAT|. This file is located in the directory where
  183. you installed \fpk. The installation program doesn't modify the
  184. \file{AUTOEXEC.BAT}, since many people (including the authors of \fpk)
  185. don't like this.
  186. You can choose to insert a call to this batch file in your \file{AUTOEXEC.BAT}
  187. file, like this :
  188. \begin{verbatim}
  189. CALL C:\PP\SET_PP.BAT
  190. \end{verbatim}
  191. (This is assuming that you installed \fpk in the default location.)
  192. In order to run \fpk from any directory on your system, you must extend
  193. your path variable to contain the \verb|C:\PP\BIN| directory.
  194. You can choose to do this in your \file{AUTOEXEC.BAT} file, but you can also
  195. insert a statement in the \verb|SET_PP.BAT| file. Whatever the location you
  196. choose, It should look something like this :
  197. \begin{verbatim}
  198. SET PATH=%PATH%;C:\PP\BIN
  199. \end{verbatim}
  200. (Again, assuming that you installed in the default location).
  201. If you want to use the graphic drivers you must modify the
  202. environment variable \var{GO32}. Instructions for doing this can be found
  203. in the documentation of the Graph unit, at the InitGraph procedure.
  204. \subsubsection{Optional Installation: The coprocessor emulation}
  205. For people who have an older CPU type, without math coprocessor (i387)
  206. it is necessary to install a coprocessor emulation, since \fpk uses the
  207. coprocessor to do all floating point operations.
  208. The installation of the coprocessor emulation is handled by the
  209. installation program (\file{INSTALL.EXE}). However,
  210. the installation program has currently a bug: If you select the
  211. coprocessor emulation the program ignores this and you must do
  212. this by hand. You should change the \var{GO32} environment variable in
  213. the \verb|SET_PP.BAT| file, as follows:
  214. \begin{verbatim}
  215. SET GO32=emu C:\PP\DRIVERS\EMU387
  216. \end{verbatim}
  217. %
  218. %
  219. % Installing under Linux
  220. \subsection{Installing under Linux}
  221. \subsubsection{Mandatory installation steps.}
  222. The \linux distribution of \fpk comes in two flavors:
  223. \begin{itemize}
  224. \item an \file{aout} version, and
  225. \item an \file{ELF} version.
  226. \end{itemize}
  227. If you don't know which of these flavors you must use, contact you system
  228. administrator, and he will tell you. When that doesn't get you further, try
  229. the \file{ELF} distribution. \file{aout} systems are outdated, and may not be
  230. supported any more in the future.
  231. Both flavors are shipped in \file{tar} archive files.
  232. This means that you should untar them, in some directory where you have
  233. write permission, using the following command:
  234. \begin{verbatim}
  235. tar -xvf fpk.tar
  236. \end{verbatim}
  237. We supposed here that you downloaded the file \file{fpk.tar} somewhere
  238. from the Internet.
  239. When the files are untarred, you will be left with more archive files, and
  240. two install programs: an installation shell script, and a X-windows
  241. installation program. Both have the same functionality.
  242. To install \fpk, all that you need to do now is give the following command:
  243. \begin{verbatim}
  244. ./install.sh
  245. \end{verbatim}
  246. Or, if you have the XForms libraries, you can start the X-Windows based
  247. program.
  248. \begin{verbatim}
  249. ./fpkinstall
  250. \end{verbatim}
  251. And then you must answer some questions. They're very simple, they're
  252. concerned with 2 things :
  253. \begin{enumerate}
  254. \item Places where you can install different things.
  255. \item Deciding if you want to install certain components (such as sources
  256. and demo programs).
  257. \end{enumerate}
  258. If you run the installation program/script as \var{root}, you can just accept all installation
  259. defaults. If you don't run as \var{root}, you must take care to supply the
  260. installation program with directory names where you have write permission,
  261. as it will attempt to create the directories you specify.
  262. In principle, you can install it wherever you want, though.
  263. Whatever the installation program you used,
  264. at the end of installation, the installation program will generate a
  265. configuration file for the \fpk compiler which reflects the settings
  266. that you chose. It will install this file in the \file{/etc} directory, (if
  267. you are not installing as \var{root}, this will fail, and in the
  268. directory where you installed the libraries.
  269. If you want the \fpk compiler to use this configuration file, it must be
  270. present in \file{/etc}, or you can set the environment variable
  271. \var{PPC\_CONFIG\_PATH}. Under \file{csh}, you can do this by adding a
  272. \begin{verbatim}
  273. setenv PPC_CONFIG_PATH /usr/lib/ppc/0.9.1
  274. \end{verbatim}
  275. line to your \file{.login} file in your home directory.
  276. (see also the next section)
  277. \subsubsection{Optional configuration steps}
  278. You may wish to set some environment variables. The \linux version of \fpk
  279. recognizes the following variables :
  280. \begin{itemize}
  281. \item \verb|PPC_EXEC_PATH| contains the directory where '\file{as}' and
  282. '\file{ld}' are. (default \file{/usr/bin})
  283. \item \verb|PPC_GCCLIB_PATH| contains the directory where \file{libgcc.a} is (no default)
  284. \item \verb|PPC_CONFIG_PATH| specifies an alternate path to find
  285. \file{ppc386.cfg} (default \file{/etc})
  286. \item \verb|PPC_ERROR_FILE| specifies the path and name of the error-definition file.
  287. (default \file{/usr/lib/ppc/errorE.msg})
  288. \end{itemize}
  289. These locations are, however, set in the sample configuration file which is
  290. built at the end of the installation process, except for the
  291. \verb|PPC_CONFIG_PATH| variable, which you must set if you didn't install
  292. things in the default places.
  293. \subsubsection{finally}
  294. Also distributed in \fpk is a README file. It contains the latest
  295. instructions for installing \fpk, and should always be read first.
  296. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  297. % Testing the compiler
  298. \section{Testing the compiler}
  299. After the installation is completed and the environment variables are
  300. set as described above, your first program can be compiled.
  301. Included in the \fpk distribution are some demonstration programs,
  302. showing what the compiler can do.
  303. You can test if the compiler functions correctly by trying to compile
  304. these programs.
  305. The compiler is called
  306. \begin{itemize}
  307. \item \file{PPC386.EXE} under \dos, and
  308. \item \file{ppc386} under \linux
  309. \end{itemize}
  310. To compile a program (e.g \verb|demo\hello.pp|) simply type :
  311. \begin{verbatim}
  312. ppc386 -a hello
  313. \end{verbatim}
  314. at the command prompt. The option -a is needed currently to call
  315. the external assembler.
  316. This needed option will disappear when the the internal assembler works stable.
  317. but at the moment it is a mandatory option.
  318. If you got no error messages, the compiler has generated an executable
  319. called \file{hello} (no extension) under \linux, and a file \file{hello.exe}
  320. under \dos.
  321. To execute the program, simply type :
  322. \begin{verbatim}
  323. hello
  324. \end{verbatim}
  325. If all went well, you should see the following friendly greeting:
  326. \begin{verbatim}
  327. Hello world
  328. \end{verbatim}
  329. In the \dos case, this friendly greeting may be preceded by some ugly
  330. message from the \file{GO32} extender program. This unfriendly behavior can
  331. be switched off by setting the \file{GO32} environment variable.
  332. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  333. % Usage
  334. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  335. \chapter{Compiler usage}
  336. Here we describe the essentials to compile a program and a unit.
  337. We also describe how to make a stand-alone executable of the
  338. compiled program under \dos. For more advanced uses of the compiler,
  339. see the section on configuring the compiler, and the
  340. \progref.
  341. The examples in this section suppose that you have a \file{ppc386.cfg} which
  342. is set up correctly, and which contains at least the path setting for the
  343. RTL units. In principle this file is generated by the installation program.
  344. You may have to check that it is in the correct place (see section
  345. \ref{se:config_file} for more information on this).
  346. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  347. % Compiling a program
  348. \section{Compiling a program}
  349. Compiling a program is very simple. Assuming that you have a program source
  350. in the file \file{prog.pp}, you can compile this with the following command:
  351. \begin{verbatim}
  352. ppc386 [options] prog.pp
  353. \end{verbatim}
  354. The square brackets [] indicate that what is between them is optional.
  355. If your program file has the \file{.pp} or \file{.pas} extension,
  356. you can omit this on the command line, e.g. in the previous example you
  357. could have typed:
  358. \begin{verbatim}
  359. ppc386 [options] prog
  360. \end{verbatim}
  361. If all went well, the compiler will produce an executable, or, for version 1
  362. of the \dos extender, a file which can be converted to an executable.
  363. Under \linux and version 2 of the \dos extender, the file you obtained is
  364. the executable. You can execute it straight away, you don't need to do
  365. anything else. Under \dos,
  366. additional processing is required. See the section on creating an
  367. executable.
  368. You will notice that there are also other files in your directory, with
  369. extensions \file{.o} and \file{.s}. These contain, respectively,
  370. the assembler sources and the object files for your program. You can
  371. safely delete the assembler file, you don't need it any
  372. more\footnote{One day this will be done automatically.}. If you compiled a
  373. program, you can delete the object file (\file{.o}), but not if you compiled
  374. a unit. Then the object file contains the code of the unit, and will be
  375. linked in any program that uses the unit you compiled, so you shpuldn't
  376. remove it.
  377. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  378. % Compiling a unit
  379. \section{Compiling a unit}
  380. Compiling a unit is not essentially different from compiling a program.
  381. The difference is mainly that the linker isn't called in this case.
  382. To compile a unit in the file \file{foo.pp}, just type :
  383. \begin{verbatim}
  384. ppc386 foo
  385. \end{verbatim}
  386. Recall the remark about file extensions in the previous section.
  387. When all went well, you will be left with 2 (two) unit files:
  388. \begin{enumerate}
  389. \item \file{foo.ppu} This is the file describing the unit you just
  390. compiled.
  391. \item \file{foo.o} This file contains the actual code of the unit.
  392. This file will eventually end up in the executables.
  393. \end{enumerate}
  394. Both files are needed if you plan to use the unit for some programs.
  395. So don't delete them. If you want to distribute the unit, you must
  396. provide both the \file{.ppu} and \file{.o} file. One is useless without the
  397. other.
  398. The file containing the assembler (extension \file{.s}) can safely be
  399. deleted. You don't need it anymore.
  400. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  401. % Creating an executable for GO32V1, PMODE/DJ targets
  402. \section{Creating an executable for GO32V1, PMODE/DJ targets}
  403. This section applies only to \dos users. \linux users can skip this
  404. section (unless they're cross-compiling)
  405. %
  406. %
  407. % GO32V1
  408. \subsection{GO32V1}
  409. When compiling under \dos, GO32V2 is the default target. However, if you use
  410. go32V1 (using the \var{-TDOS} switch), the
  411. compilation process leaves you with a file which you cannot execute right away.
  412. There are 2 things you can do when compiling has finished.
  413. The first thing is to use the \dos extender from D.J. Delorie to execute
  414. your program :
  415. \begin{verbatim}
  416. go32 prog
  417. \end{verbatim}
  418. This is fine for testing, but if you want to use a program regularly, it
  419. would be easier if you could just type the program name, i.e.
  420. \begin{verbatim}
  421. prog
  422. \end{verbatim}
  423. This can be accomplished by making a \dos executable of your compiled program.
  424. There two ways to create a \dos executable (under \dos only):
  425. \begin{enumerate}
  426. \item if the \file{GO32.EXE} is already
  427. installed on the computers where the program should run, you must
  428. only copy a program called \file{STUB.EXE} at the begin of
  429. the AOUT file. This is accomplished with the \file{AOUT2EXE.EXE} program.
  430. which comes with the compiler:
  431. \begin{verbatim}
  432. AOUT2EXE PROG
  433. \end{verbatim}
  434. and you get a \dos executable which loads the \file{GO32.EXE} automatically.
  435. the \file{GO32.EXE} executable must be in current directory or be
  436. in a directory in the \var{PATH} variable.
  437. \item
  438. The second way to create a \dos executable is to put
  439. \file{GO32.EXE} at the beginning of the \file{AOUT} file. To do this, at the
  440. command prompt, type :
  441. \begin{verbatim}
  442. COPY /B GO32.EXE+PROG PROG.EXE
  443. \end{verbatim}
  444. (assuming \fpk created a file called \file{PROG}, of course.)
  445. This becomes then a stand-alone executable for \dos, which doesn't need the
  446. \file{GO32.EXE} on the machine where it should run.
  447. \end{enumerate}
  448. %
  449. %
  450. % PMODE/DJ
  451. \subsection{PMODE/DJ}
  452. You can also use the PMODE/DJ extender to run your \fpk applications.
  453. To make an executable which works with the PMODE extender, you can simply
  454. create an GO32V2 executable (the default), and then convert it to a PMODE
  455. executable with the following two extra commands:
  456. \begin{enumerate}
  457. \item First, strip the GO32V2 header of the executable:
  458. \begin{verbatim}
  459. EXE2COFF PROG.EXE
  460. \end{verbatim}
  461. (we suppose that \file{PROG.EXE} is the program generated by the compilation
  462. process.
  463. \item Secondly, add the PMODE stub:
  464. \begin{verbatim}
  465. COPY /B PMODSTUB.EXE+PROG PROG.EXE
  466. \end{verbatim}
  467. If the \file{PMODSTUB.EXE} file isn't in your local directory, you need to
  468. supply the whole path to it.
  469. \end{enumerate}
  470. That's it. No additional steps are needed to create a PMODE extender
  471. executable.
  472. Be aware, though, that the PMODE extender doesn't support virtual memory, so
  473. if you're short on memory, you may run unto trouble. Also, officially there
  474. is not support for the PMODE/DJ extender. It just happens that the compiler
  475. and some of the programs it generates, run under this extender too.
  476. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  477. % Reducing the size of your program
  478. \section{Reducing the size of your program}
  479. When you created your program, it is possible to reduce its size. This
  480. is possible, because the compiler leaves a lot of information in the
  481. program which, strictly speaking, isn't required for the execution of
  482. it. The surplus of information can be removed with a small program
  483. called \file{strip}. It comes with the \var{GO32} development
  484. environment under \dos, and is standard on \linux machines where you can
  485. do development. The usage is simple. Just type
  486. \begin{verbatim}
  487. strip prog
  488. \end{verbatim}
  489. On the command line, and the \file{strip} program will remove all unnecessary
  490. information from your program. This can lead to size reductions of up to
  491. 30 \%.
  492. You can use the \var{-Xs} switch to let the compiler do this stripping
  493. automatically. Under \linux, you can set the \var{-k-s} option, which does
  494. the same.
  495. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  496. % Problems
  497. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  498. \chapter{Compiling problems}
  499. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  500. % General problems
  501. \section{General problems}
  502. \begin{itemize}
  503. \item \textbf{IO-error -2 at ...} : Under \linux you can get this message at
  504. compiler startup. It means typically that the compiler doesn't find the
  505. error definitions file. You can correct this mistake with the \var{-Fr}
  506. option under \linux. (\seeo{Fr})
  507. \item \textbf {Error : File not found : xxx} This typically happens when
  508. your unit path isn't set correctly. Remember that the compiler looks for
  509. units only in the current directory, and in the directory where the compiler
  510. itself is. If you want it to look somewhere else too, you must explicitly
  511. tell it to do so using the \var{-Up} option (\seeo{Up}).
  512. \end{itemize}
  513. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  514. % Problems you may encounter under DOS
  515. \section{Problems you may encounter under DOS}
  516. \begin{itemize}
  517. \item \textbf{No space in environment}.\\
  518. An error message like this can occur, if you call
  519. \verb|SET_PP.BAT| in the \file{AUTOEXEC.BAT}.\\
  520. To solve this problem, you must extend your environment memory.
  521. To do this, search a line in the \file{CONFIG.SYS} like
  522. \begin{verbatim}
  523. SHELL=C:\DOS\COMMAND.COM
  524. \end{verbatim}
  525. and change it to the following:
  526. \begin{verbatim}
  527. SHELL=C:\DOS\COMMAND.COM /E:1024
  528. \end{verbatim}
  529. You may just need to specify a higher value, if this parameter is already set.
  530. \item \textbf{ Coprocessor missing}\\
  531. If the compiler writes
  532. a message that there is no coprocessor, install
  533. the coprocessor emulation.
  534. \item \textbf{Not enough DPMI memory}\\
  535. If you want to use the compiler with \var{DPMI} you must have at least
  536. 7-8 MB free \var{DPMI} memory.
  537. \end{itemize}
  538. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  539. % Configuration.
  540. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  541. \chapter{Compiler configuration}
  542. The output of the compiler can be controlled in many ways. This can be done
  543. essentially in two distinct ways:
  544. \begin{itemize}
  545. \item Using command-line options.
  546. \item Using the configuration file: \file{ppc386.cfg}.
  547. \end{itemize}
  548. The compiler first reads the configuration file. Only then the command line
  549. options are checked. This creates the possibility to set some basic options
  550. in the configuration file, and at the same time you can still set some
  551. specific options when compiling some unit or program. First we list the
  552. command line options, and then we explain how to specify the command
  553. line options in the configuration file. When reading this, keep in mind
  554. that the options are case sensitive. While this is customary for \linux, it
  555. isn't under \dos.
  556. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  557. % Using the command-line options
  558. \section{Using the command-line options}
  559. The available options are listed by category:
  560. %
  561. %
  562. % General options
  563. \subsection{General options}
  564. \begin{description}
  565. \item[-h] if you specify this option, the compiler outputs a list of all options,
  566. and exits after that.
  567. \olabel{h}
  568. \item[-i] This option tells the compiler to print the copyright information.
  569. \olabel{i}
  570. \item[-l] This option tells the compiler to print the \fpk logo on standard
  571. output. It also gives you the \fpk version number.
  572. \olabel{l}
  573. \item[-Lx] Set the language the compiler uses for its messages.
  574. \olabel{L}
  575. \var{x} can be one of the following:
  576. \begin{itemize}
  577. \item \textbf{D} : Use German.
  578. \item \textbf{E} : Use English.
  579. \end{itemize}
  580. \end{description}
  581. %
  582. %
  583. % Options for getting feedback
  584. \subsection{Options for getting feedback}
  585. \begin{description}
  586. \item[-qxx] This option tells the compiler to print on stdout some
  587. information on what it is doing. xx can be one of the following:
  588. \olabel{q}
  589. \begin{itemize}
  590. \item \textbf{x is empty} : Be quiet. Don't output anything
  591. \item \textbf{-} : Give some information.
  592. \item \textbf{--} : Give a lot of information.
  593. \end{itemize}
  594. This is an obsolete option, and is kept only for backwards
  595. compatibility. It may disappear in the future.\\
  596. \item[-vxxx] Be verbose. \var{xxx} is a combination of the following :
  597. \olabel{v}
  598. \begin{itemize}
  599. \item \var{e} : Tells the compiler to show only errors. This option is on by default.
  600. \item \var{i} : Tells the compiler to show some general information.
  601. \item \var{w} : Tells the compiler to issue warnings.
  602. \item \var{n} : Tells the compiler to issue notes.
  603. \item \var{l} : Tells the compiler to show the line numbers as it processes a
  604. file. Numbers are shown per 100.
  605. \item \var{u} : Tells the compiler to print the names of the files it opens.
  606. \item \var{t} : Tells the compiler to print the names of the files it tries
  607. to open.
  608. \item \var{p} : Tells the compiler to print the names of procedures and
  609. functions as it is processing them.
  610. \item \var{c} : Tells the compiler to warn you when it processes a
  611. conditional.
  612. \item \var{m} : Tells the compiler to write which macros are defined.
  613. \item \var{d} : Tells the compiler to write other debugging info.
  614. \end{itemize}
  615. \item[-w] When this option is specified, the compiler issues warning. To
  616. turn off warnings, specify \var{-w-}\\
  617. This option is obsolete. and is kept only for backwards compatibility. It
  618. may disappear in the future.
  619. \olabel{w}
  620. \end{description}
  621. %
  622. %
  623. % Options concerning files and directories
  624. \subsection{Options concerning files and directories}
  625. \begin{description}
  626. \item [-exxx] (\linux only) \file{xxx} specifies the directory where the
  627. compiler can find the executables \file{as} (the assembler) and \file{ld} (the
  628. compiler).
  629. \olabel{e}
  630. \item [-Fexxx] This option tells the compiler to write errors, etc. to
  631. the file in \file{xxx}.
  632. \olabel{Fe}
  633. \item [-Fgxxx] (\linux only) \file{xxx} specifies the path where the compiler
  634. can find the \gnu C library.
  635. \olabel{Fg}
  636. \item [-Frxxx] (\linux only) \file{xxx} specifies the path where the
  637. compiler can find the error-definitions file.
  638. \olabel{Fr}
  639. \item [-Upxxx] \olabel{Up} Tells the compiler to add \file{xxx} to the path where to find
  640. units. \\
  641. By default, the compiler only searches for units in the current directory
  642. and the directory where the compiler itself resides. This option tells the
  643. compiler also to look in the directory \file{xxx}.
  644. \end{description}
  645. % Options controlling the kind of output.
  646. \subsection{Options controlling the kind of output.}
  647. for more information on these options, see also \progref
  648. \begin{description}
  649. \item [-a] \olabel{a} Tells the compiler to generate an assembler source file, and to
  650. call an external assembler (\file{as}) to assemble this file. The file will
  651. not be deleted.
  652. \item [-Axxx] \olabel{A}specifies what kind of assembler should be generated . Here
  653. \var{xxx} is one of the following :
  654. \begin{itemize}
  655. \item \textbf{att} : AT\&T assembler.
  656. \item \textbf{o} : A unix .o (object) file.
  657. \item \textbf{obj} : A OMF file for using the NASM assembler.
  658. \item \textbf{nasm} : a coff file using the NASM assembler.
  659. \item \textbf{wasm} : An assembler file for the Microsoft/Borland/Watcom assembler.
  660. \end{itemize}
  661. \item [-Chxxx] \olabel {Ch} Reserves \var{xxx} bytes heap.
  662. \item [-Ci] \olabel{Ci} Generate Input/output checking code.
  663. \item [-Co] \olabel{Co} Generate Integer overflow checking code.
  664. \item [-Cr] \olabel{Cr} Generate Range checking code.
  665. \item [-Csxxx] \olabel{Cs} Set stack size to \var{xxx}. (\ostwo only).
  666. \item [-dxxx] \olabel{d} Define the symbol name \var{xxx}. This can be used
  667. to conditionally compile parts of your code.
  668. \item [-g] \olabel{g} Generate debugging information for debugging with
  669. \file{gdb}.
  670. \item[-On] \olabel{O} optimize the compiler's output; \var{n} can have one
  671. of the following values :
  672. \begin{description}
  673. \item[a] simple optimizations
  674. \item[g] optimize for size
  675. \item[G] optimize for time
  676. \item[x] optimize maximum
  677. \item[2] optimize for Pentium II (tm)
  678. \item[3] optimize for i386
  679. \item[4] optimize for i486
  680. \item[5] optimize for Pentium (tm)
  681. \item[6] optimizations for PentiumPro (tm)
  682. \end{description}
  683. The exact effect of these effects can be found in the appendices of the
  684. \progref.
  685. \item [-s] \olabel{s} Tells the compiler not to call the assembler and linker.
  686. You must specify also \var{-a} if you specify this.
  687. \item[-Txxx] \olabel{T}Specifies the target operating system. \var{xxx} can be one of
  688. the following:
  689. \begin{itemize}
  690. \item \textbf{DOS} : \dos and the DJ DELORIE extender.
  691. \item \textbf{OS2} : OS/2 (2.x) (this is still under development).
  692. \item \textbf{LINUX} : \linux.
  693. \item \textbf{WIN32} : Windows 32 bit (this is still under development).
  694. \item \textbf{GO32V2} : \dos and version 2 of the DJ DELORIE extender.
  695. \end{itemize}
  696. \item [-Xx] \olabel{X} executable options. This tells the compiler what
  697. kind of \linux executable should be generated. the parameter \var{x}
  698. can be one of the following:
  699. \begin{itemize}
  700. \item \textbf{e} : (\linux only) Create an \file{ELF} executable (default).
  701. \item \textbf{c} : (\linux only) Link with the C library. You should only use this when
  702. you start to port \fpk to another operating system.
  703. \item \textbf{s} : (\dos only) Strip the symbols from the executable.
  704. \end{itemize}
  705. \end{description}
  706. %
  707. %
  708. % Options concerning the sources (language options)
  709. \subsection{Options concerning the sources (language options)}
  710. for more information on these options, see also \progref
  711. \begin{description}
  712. \item [-Rxxx] \olabel{R} Specifies what assembler you use in your \var{asm} assembler code
  713. blocks. Here \var{xxx} is one of the following:
  714. \begin{description}
  715. \item [att\ ] \var{asm} blocks contain AT\&T assembler.
  716. \item [intel] \var{asm} blocks contain Intel assembler.
  717. \item [direct] \var{asm} blocks should be copied as-is in the assembler
  718. file.
  719. \end{description}
  720. \item [-S2] \olabel{Stwo} Switch on Delphi 2 extensions.
  721. \item [-Sann] \olabel{Sa} How severe should the compiler check your code ?
  722. \var{nn} can be one of the following:
  723. \begin{itemize}
  724. \item \var{0} : Only ANSI Pascal expressions allowed.
  725. \item \var{1} : Do not necessarily assign function results to variables.
  726. \item \var{2} : Address operator \var{@} returns a typed pointer.
  727. \item \var{4} : Assignment results are typed. (This allows constructs like
  728. \var{a:=b:=0}. See also ...
  729. \item \var{9} : Allows expressions with no side effect. \remark{Florian ???}
  730. \end{itemize}
  731. \item [-Sc] \olabel{Sc} Support C-style operators, i.e. \var{*=, +=, /= and
  732. -=}.
  733. \item [-Sg] \olabel{Sg} Support the \var{label} and \var{goto} commands.
  734. \item [-Si] \olabel{Si} Support \var{C++} style INLINE.
  735. \item [-Sm] \olabel{Sm} Support C-style macros.
  736. \item [-So] \olabel{So} Try to be Borland TP compatible (no function
  737. overloading etc.).
  738. \item [-Ss] \olabel{Ss} The name of constructors must be \var{init}, and the
  739. name of destructors should be \var{done}.
  740. \item [-St] \olabel{St} Allow the \var{static} keyword in objects.
  741. \item [-Un] \olabel{Un} Do not check the unit name. (Normally, the unit name
  742. is the same as the filename. This option allows both to be different.)
  743. \item [-Us] \olabel{Us} Compile a system unit. This option causes the
  744. compiler to define only some very basic types.
  745. \end{description}
  746. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  747. % Using the configuration file
  748. \section{Using the configuration file}
  749. \label{se:config_file}
  750. Using the configuration file \file{ppc386.cfg} is an alternative to command
  751. line options. When a configuration file is found, it is read, and the lines
  752. in it are treated like you typed them on the command line. They are treated
  753. before the options that you type on the command line.
  754. The compiler looks for the \file{ppc386.cfg} file in the following places :
  755. \begin{enumerate}
  756. \item The current directory.
  757. \item Under \dos, the directory where the compiler is. Under \linux,
  758. the compiler looks in the \file{/etc} directory, or, if specified,
  759. the directory in the \var{PPC\_CONFIG\_PATH} environment variable.
  760. \end{enumerate}
  761. When the compiler has finished reading the configuration file, it continues
  762. to treat the command line options.
  763. One of the command-line options allows you to specify a second configuration
  764. file: Specifying \file{@foo} on the command line will open file \file{foo},
  765. and read further options from there. When the compiler has finished reading
  766. this file, it continues to process the command line.
  767. An important feature in the configuration file is that you can specify
  768. sections. They behave much like conditional defines.
  769. Suppose the following configuration file (named \file{myconf})
  770. \begin{verbatim}
  771. -a
  772. #section first
  773. -Up/some_path
  774. #section second
  775. -Up/other_path.
  776. \end{verbatim}
  777. When you invoke the compiler as follows:
  778. \begin{verbatim}
  779. ppc386 -dfirst @myconf foo.pp
  780. \end{verbatim}
  781. then the compiler will read the part of the configuration file coming before
  782. the line containing \var{\#section second}. As a result the unit search path will be set
  783. to \file{/some\_path}.
  784. If, on the other hand, you invoke the compiler as
  785. \begin{verbatim}
  786. ppc386 -dsecond @myconf foo.pp
  787. \end{verbatim}
  788. Then the configuration file will be read as if the part between
  789. \var{\#section first} and \var{\#section second} didn't exist, resulting
  790. in a unit search path of \file{/other\_path}.
  791. If you put a \var{\#section common} on a line, everything that follows this
  792. keyword will be read, whatever the defined constants.
  793. In short, the \var{\#define} keywords act as conditionals.
  794. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  795. % Porting.
  796. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  797. \chapter{Porting Turbo Pascal Code}
  798. \fpk was designed to resemble Turbo Pascal as closely as possible. There
  799. are, of course, restrictions. Some of these are due to the fact that \fpk is
  800. a 32-bit compiler. Other restrictions result from the fact that \fpk works
  801. on more than one operating system.
  802. In general we can say that if you keep your program code close to ANSI
  803. Pascal, you will have no problems porting from Turbo Pascal, or even Delphi, to
  804. \fpk. To a large extent, the constructs defined by Turbo Pascal are
  805. supported.
  806. In the following sections we will list the Turbo Pascal constructs which are
  807. not supported in \fpk, and we will list in what ways \fpk extends the Turbo
  808. Pascal language.
  809. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  810. % Things that will not work
  811. \section{Things that will not work}
  812. Here we give a list of things which are defined/allowed in Turbo Pascal, but
  813. which are not supported by \fpk. Where possible, we indicate the reason.
  814. \begin{enumerate}
  815. \item Parameter lists of previously defined functions and procedures must
  816. match exactly. The reason for this is the function overloading mechanism of
  817. \fpk. (however, \seeo{So})
  818. \item \var {(* ... *)} as comment delimiters are not allowed in versions
  819. older than 0.9.1. This can easily be remedied with a grown-up editor.
  820. \item The \var{MEM, MEMW, MEML} and \var{PORT} variables for memory and port
  821. access are not available. This is due to the operating system. Under
  822. \dos, the extender unit (\file {GO32.PPU} provides functions to remedy this.
  823. \item \var{PROTECTED, PUBLIC, TRY, THROW, EXCEPTION} are reserved words.
  824. This means you cannot create procedures or variables with the same name.
  825. While they are not reserved words in Turbo Pascal, they are in Delphi.
  826. \item The reserved words \var{FAR, NEAR} are ignored. This is
  827. because \fpk is a 32 bit compiler, so they're obsolete.
  828. \item \var{INTERRUPT} only will work on a DOS machine.
  829. \item Boolean expressions are only evaluated until their result is completely
  830. determined. The rest of the expression will be ignored.
  831. \item At the moment of writing, the assembler syntax used in \fpk is \var{AT\&T}
  832. assembler syntax. This is mainly because \fpk uses \gnu \var{as}.
  833. \item Turbo Vision is not available.
  834. \item The 'overlay' unit is not available. It also isn't necessary, since
  835. \fpk is a 32 bit compiler, so program size shouldn't be a point.
  836. \item There are more reserved words. (see appendix \ref{ch:reserved} for a
  837. list of all reserved words.)
  838. \item The command-line parameters of the compiler are different.
  839. \item The compiler switches behave different.
  840. \item Units are not binary compatible.
  841. \end{enumerate}
  842. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  843. % Things which are extra
  844. \section{Things which are extra}
  845. Here we give a list of things which are possible in \fpk, but which
  846. didn't exist in Turbo Pascal or Delphi.
  847. \begin{enumerate}
  848. \item There are more reserved words. (see appendix \ref{ch:reserved} for a
  849. list of all reserved words.)
  850. \item Functions can also return complex types, such as records and arrays.
  851. \item You can handle function results in the function itself, as a variable.
  852. Example
  853. \begin{verbatim}
  854. function a : longint;
  855. begin
  856. a:=12;
  857. while a>4 do
  858. begin
  859. {...}
  860. end;
  861. end;
  862. \end{verbatim}
  863. The example above would work with TP, but the compiler would assume
  864. that the \var{a>4} is a recursive call. To do a recursive call in
  865. this you must append \var{()} behind the function name:
  866. \begin{verbatim}
  867. function a : longint;
  868. begin
  869. a:=12;
  870. { this is the recursive call }
  871. if a()>4 then
  872. begin
  873. {...}
  874. end;
  875. end;
  876. \end{verbatim}
  877. \item There is partial support of Delphi constructs. (see the \progref for
  878. more information on this).
  879. \item The \var{exit} call accepts a return value for functions.
  880. \begin{verbatim}
  881. function a : longint;
  882. begin
  883. a:=12;
  884. if a>4 then
  885. begin
  886. exit(a*67); {function result upon exit is a*67 }
  887. end;
  888. end;
  889. \end{verbatim}
  890. \item \fpk supports function overloading. That is, you can define many
  891. functions with the same name, but with different arguments. For example:
  892. \begin{verbatim}
  893. procedure DoSomething (a : longint);
  894. begin
  895. {...}
  896. end;
  897. procedure DoSomething (a : real);
  898. begin
  899. {...}
  900. end;
  901. \end{verbatim}
  902. You can then call procedure \var{DoSomething} with an argument of type
  903. \var{Longint} or \var{Real}.\\
  904. This feature has the consequence that a previously declared function must
  905. always be defined with the header completely the same:
  906. \begin{verbatim}
  907. procedure x (v : longint); forward;
  908. {...}
  909. procedure x;{ This will overload the previously declared x}
  910. begin
  911. {...}
  912. end;
  913. \end{verbatim}
  914. This construction will generate a compiler error, because the compiler
  915. didn't find a definition of \var{procedure x (v : longint);}. Instead you
  916. should define your procedure x as:
  917. \begin{verbatim}
  918. procedure x (v : longint);
  919. { This correctly defines the previously declared x}
  920. begin
  921. {...}
  922. end;
  923. \end{verbatim}
  924. \end{enumerate}
  925. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  926. % Turbo Pascal compatibility mode
  927. \section{Turbo Pascal compatibility mode}
  928. When you compile a program with the \var{-So} switch, the compiler will
  929. attempt to mimic the Turbo Pascal compiler in the following ways:
  930. \begin{itemize}
  931. \item Assigning a procedural variable doesn't require a @ operator. One of
  932. the differences between Turbo Pascal and \fpk is that the latter requires
  933. you to specify an address operator when assigning a value to a procedural
  934. variable. In Turbo Pascal compatibility mode, this is not required.
  935. \item Procedure overloading is disabled.
  936. \item Forward defined procedures don't need the full parameter list when
  937. they are defined. Due to the procedure overloading feature of \fpk, you must
  938. always specify the parameter list of a function when you define it, even
  939. when it was declared earlier with \var{Forward}. In Turbo Pascal
  940. compatibility mode, there is no function overloading, hence you can omit the
  941. parameter list:
  942. \begin{verbatim}
  943. Procedure a (L : Longint); Forward;
  944. ...
  945. Procedure a ; { No need to repeat the (L : Longint) }
  946. begin
  947. ...
  948. end;
  949. \end{verbatim}
  950. \item recursive function calls are handled dfferently. Consider the
  951. following example :
  952. \begin{verbatim}
  953. Function expr : Longint;
  954. begin
  955. ...
  956. Expr:=L:
  957. Writeln (Expr);
  958. ...
  959. end;
  960. \end{verbatim}
  961. In Turbo Pascal compatibility mode, the function will be called recursively
  962. when the \var{writeln} statement is processed. In \fpk, the function result
  963. will be printed. In order to call the function recusively under \fpk, you
  964. need to implement it as follows :
  965. \begin{verbatim}
  966. Function expr : Longint;
  967. begin
  968. ...
  969. Expr:=L:
  970. Writeln (Expr());
  971. ...
  972. end;
  973. \end{verbatim}
  974. \item Any text after the final \var{End.} statement is ignored. Normally,
  975. this text is processed too.
  976. \item You cannot assign procedural variables to void pointers.
  977. \item The @ operator is typed when applied on procedures.
  978. \item You cannot nest comments.
  979. \end{itemize}
  980. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  981. % Utilities.
  982. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  983. \chapter{Utilities and units that come with Free Pascal}
  984. Besides the compiler and the Run-Time Library, \fpk comes with some utility
  985. programs and units. Here we list these programs and units.
  986. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  987. % Supplied programs
  988. \section{Supplied programs}
  989. \begin{itemize}
  990. \item \file{dumppu} is a program which shows the contents of a \fpk unit. It
  991. comes in source form, and must be compiled before you can use it. Once
  992. compiled, you can just issue the following command
  993. \begin{verbatim}
  994. dumppu foo.ppu
  995. \end{verbatim}
  996. to display the contents of the \file{foo.ppu} unit.
  997. \item Also distributed with Free Pascal comes a series of demonstration programs.
  998. These programs have no other purpose than demonstrating the capabilities of
  999. \fpk. They are located in the \file{demo} directory of the sources.
  1000. \item All example programs of the documentation are available. Check out the
  1001. directories that end on \file{ex} in the documentation sources. There you
  1002. wll find all example sources.
  1003. \end{itemize}
  1004. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1005. % Supplied units
  1006. \section{Supplied units}
  1007. Here we list the units that come with the \fpk distribution. Since there is
  1008. a difference in the supplied units per operating system, we list them
  1009. separately per system.
  1010. %
  1011. %
  1012. % Under DOS
  1013. \subsection{Under DOS}
  1014. \begin{itemize}
  1015. \item \seestrings\ This unit provides basic
  1016. string handling routines for the \var{pchar} type, comparable to similar
  1017. routines in standard \var{C} libraries.
  1018. \item \seeobjects\ This unit provides basic
  1019. routines for handling objects.
  1020. \item \seedos\ This unit provides basic routines for
  1021. accessing the operating system \dos. It provides almost the same
  1022. functionality as the Turbo Pascal unit.
  1023. \item \seeprinter\ This unit provides all you
  1024. need for rudimentary access to the printer.
  1025. \item \seegetopts\ This unit gives you the
  1026. \gnu \var{getopts} command-line arguments handling mechanism.
  1027. It also supports long options.
  1028. \item \seecrt\ This unit provides basic screen
  1029. handling routines. It provides the same functionality as the Turbo Pascal \var{CRT}
  1030. unit.
  1031. \item \seegraph\ This unit provides basic graphics
  1032. handling, with routines to draw lines on the screen, display texts etc. It
  1033. provides the same functions as the Turbo Pascal unit.
  1034. \item \seego\ This unit provides access to possibilities of the \var{GO32}
  1035. \dos extender.
  1036. \end{itemize}
  1037. \remark{Florian, I don't know the full list - let me know what is available}
  1038. %
  1039. %
  1040. % Under Linux
  1041. \subsection{Under Linux}
  1042. \begin{itemize}
  1043. \item \seestrings\ This unit provides basic
  1044. string handling routines for the \var{PChar} type, comparable to similar
  1045. routines in standard \var{C} libraries.
  1046. \item \seeobjects\ This unit provides basic
  1047. routines for handling objects.
  1048. \item \seecrt\ This unit provides basic screen
  1049. handling routines. It provides the same functionality Turbo Pascal \var{CRT}
  1050. unit. It works on any terminal which supports the \var{vt100} escape
  1051. sequences.
  1052. \item \seedos\ This unit provides an emulation of the
  1053. same unit under \dos. It is intended primarily for easy porting of Pascal
  1054. programs from \dos to \linux. For good performance, however, it is
  1055. recommended to use the \var{linux} unit.
  1056. \item \seelinux This unit provides access to the
  1057. \linux operating system. It provides most file and I/O handling routines
  1058. that you may need. It implements most of the standard \var{C} library constructs
  1059. that you will find on a Unix system. If you do a lot of disk/file
  1060. operations, the use of this unit is recommended over the one you use under
  1061. Dos.
  1062. \item \seeprinter\ This unit provides an
  1063. interface to the standard Unix printing mechanism.
  1064. \item \seegetopts This unit gives you the
  1065. \gnu \var{getopts} command-line arguments handling mechanism.
  1066. It also supports long options.
  1067. \end{itemize}
  1068. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1069. % Debugging
  1070. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1071. \chapter{Debugging your Programs}
  1072. \fpk supports debug information for the \gnu debugger \var{gdb}.
  1073. This chapter describes shortly how to use this feature. It doesn't attempt
  1074. to describe completely the \gnu debugger, however.
  1075. For more information on the workings of the \gnu debugger, see the \var{gdb}
  1076. users' guide.
  1077. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1078. % Compiling your program with debugger support
  1079. \section{Compiling your program with debugger support}
  1080. First of all, you must be sure that the compiler is compiled with debugging
  1081. support. Unfortunately, there is no way to check this at run time, except by
  1082. trying to compile a program with debugging support.
  1083. To compile a program with debugging support, just specify the \var{-g}
  1084. option on the command-line, as follows:
  1085. \begin{verbatim}
  1086. ppc386 -g hello.pp
  1087. \end{verbatim}
  1088. This will generate debugging information in the executable from your
  1089. program. You will notice that the size of the executable increases
  1090. substantially because of this\footnote{A good reason not to include debug
  1091. information in an executable you plan to distribute.}.
  1092. Note that the above will only generate debug information {\var for the code
  1093. that has been generated} when compiling \file{hello.pp}. This means that if
  1094. you used some units (the system unit, for instance) which were not compiled
  1095. with debugging support, no debugging support will be available for the code
  1096. in these units.
  1097. There are 2 solutions for this problem.
  1098. \begin{enumerate}
  1099. \item Recompile all units manually with the \var{-g} option.
  1100. \item Specify the 'build' option (\var{-B}) when compiling with debugging
  1101. support. This will recompile all units, and insert debugging information in
  1102. each of the units.
  1103. \end{enumerate}
  1104. The second option may have undesirable side effects. It may be that some
  1105. units aren't found, or compile incorrectly due to missing conditionals,
  1106. etc..
  1107. If all went well, the executable now contains the necessary information with
  1108. which you can debug it using \gnu \var{gdb}.
  1109. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1110. % Using \var{gdb
  1111. \section{Using \var{gdb} to debug your program}
  1112. To use gdb to debug your program, you can start the debugger, and give it as
  1113. an option the name of your program:
  1114. \begin{verbatim}
  1115. gdb hello
  1116. \end{verbatim}
  1117. This starts the debugger, and the debugger immediately loads your program
  1118. into memory, but it does not run the program yet. Instead, you are presented
  1119. with the following (more or less) message, followed by the \var{gdb} prompt
  1120. \var{'(gdb)'}:
  1121. \begin{verbatim}
  1122. GDB is free software and you are welcome to distribute copies of it
  1123. under certain conditions; type "show copying" to see the conditions.
  1124. There is absolutely no warranty for GDB; type "show warranty" for details.
  1125. GDB 4.15.1 (i486-slackware-linux),
  1126. Copyright 1995 Free Software Foundation, Inc...
  1127. (gdb)
  1128. \end{verbatim}
  1129. To start the program you can use the \var{run} command. You can optionally
  1130. specify command-line parameters, which will then be fed to your program, for
  1131. example:
  1132. \begin{verbatim}
  1133. (gdb) run -option -anotheroption needed_argument
  1134. \end{verbatim}
  1135. If your program runs without problems, \var{gdb} will inform you of this,
  1136. and return the exit code of your program. If the exit code was zero, then
  1137. the message \var{'Program exited normally'}.
  1138. If something went wrong (a segmentation fault or so), \var{gdb} will stop
  1139. the execution of your program, and inform you of this with an appropriate
  1140. message. You can then use the other \var{gdb} commands to see what happened.
  1141. Alternatively, you can instruct \var{gdb} to stop at a certain point in your
  1142. program, with the \var{break} command.
  1143. Here is a short list of \var{gdb} commands, which you are likely to need when
  1144. debugging your program:
  1145. \begin{description}
  1146. \item [quit\ ] Exits the debugger.
  1147. \item [kill\ ] Stops a running program.
  1148. \item [help\ ] Gives help on all \var{gdb} commands.
  1149. \item [file\ ] Loads a new program into the debugger.
  1150. \item [directory\ ] Add a new directory to the search path for source
  1151. files.\\
  1152. {\em Remark:} My copy of gdb needs '.' to be added explicitly to the search
  1153. path, otherwise it doesn't find the sources.
  1154. \item [list\ ] Lists the program sources per 10 lines. As an option you can
  1155. specify a line number or function name.
  1156. \item [break\ ] Sets a breakpoint at a specified line or function
  1157. \item [awatch\ ] Sets a watch-point for an expression. A watch-point stops
  1158. execution of your program whenever the value of an expression is either
  1159. read or written.
  1160. \end{description}
  1161. for more information, see the \var{gdb} users' guide, or use the \var{'help'}
  1162. function in \var{gdb}.
  1163. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1164. % CGI.
  1165. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1166. \chapter{CGI programming in Free Pascal}
  1167. In these days of heavy WWW traffic on the Internet, CGI scripts have become
  1168. an important topic in computer programming. While CGI programming can be
  1169. done with almost any tool you wish, most languages aren't designed for it.
  1170. Perl may be a notable exception, but perl is an interpreted language, the
  1171. executable is quite big, and hence puts a big load on the server machine.
  1172. Because of its simple, almost intuitive, string handling and its easy syntax,
  1173. Pascal is very well suited for CGI programming. Pascal allows you to quickly
  1174. produce some results, while giving you all the tools you need for more
  1175. complex programming. The basic RTL routines in principle are enough to get
  1176. the job done, but you can create, with relatively little effort, some units
  1177. which can be used as a base for more complex CGI programming.
  1178. That's why, in this chapter, we will discuss the basics of CGI in \fpk.
  1179. In the subsequent, we will assume that the server for which the programs are
  1180. created, are based upon the NCSA \var{httpd} WWW server, as the examples
  1181. will be based upon the NCSA method of CGI programming\footnote{... and it's
  1182. the only WWW-server I have to my disposition at the moment.}.
  1183. The two example programs in this chapter have been tested on the command line
  1184. and worked, under the condition that no spaces were present in the name and
  1185. value pairs provided to them.
  1186. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1187. % Getting your data
  1188. \section{Getting your data}
  1189. Your CGI program must react on data the user has filled in on the form which
  1190. your web-server gave him. The Web server takes the response on the form, and
  1191. feeds it to the CGI script.
  1192. There are essentially two ways of feeding the data to the CGI script. We will
  1193. discuss both.
  1194. %
  1195. %
  1196. % Data coming through standard input.
  1197. \subsection{Data coming through standard input.}
  1198. The first method of getting your data is through standard input. This method
  1199. is invoked when the form uses a form submission method of \var{POST}.
  1200. The web browser sets three environment variables \var{REQUEST\_METHOD},
  1201. \var{CONTENT\_TYPE} and \var{CONTENT\_LENGTH}. It feeds then the results of
  1202. the different fields through standard input to the CGI script.
  1203. All the Pascal program has to do is :
  1204. \begin{itemize}
  1205. \item Check the value of the \var{REQUEST\_METHOD} environment variable. The
  1206. \var{getenv} function will retrieve this value this for you.
  1207. \item Check the value of the \var{CONTENT\_TYPE} environment variable.
  1208. \item Read \var{CONTENT\_LENGTH} characters from standard input. \var{read
  1209. (c)} with \var{c} of type \var{char} will take care of that.
  1210. \end{itemize}
  1211. if you know that the request method will always be \var{POST}, and the
  1212. \var{CONTENT\_TYPE} will be correct, then you can skip the first two steps.
  1213. The third step can be done easier: read characters until you reach the
  1214. end-of-file marker of standard input.
  1215. The following example shows how this can be achieved:
  1216. \begin{verbatim}
  1217. program cgi_post;
  1218. uses dos;
  1219. const max_data = 1000;
  1220. type datarec = record
  1221. name,value : string;
  1222. end;
  1223. var data : array[1..max_data] of datarec;
  1224. i,nrdata : longint;
  1225. c : char;
  1226. literal,aname : boolean;
  1227. begin
  1228. writeln ('Content-type: text/html');
  1229. writeln;
  1230. if getenv('REQUEST_METHOD')<>'POST' then
  1231. begin
  1232. writeln ('This script should be referenced with a METHOD of POST');
  1233. write ('If you don''t understand this, see this ');
  1234. write ('< A HREF="http://www.ncsa.uiuc.edu/SDG/Softare/Mosaic');
  1235. writeln ('/Docs/fill-out-forms/overview.html">forms overview</A>.');
  1236. halt(1);
  1237. end;
  1238. if getenv('CONTENT_TYPE')<>'application/x-www-form-urlencoded' then
  1239. begin
  1240. writeln ('This script can only be used to decode form results');
  1241. halt(1)
  1242. end;
  1243. nrdata:=1;
  1244. aname:=true;
  1245. while not eof(input) do
  1246. begin
  1247. literal:=false;
  1248. read(c);
  1249. if c='\' then
  1250. begin
  1251. literal:=true;
  1252. read(c);
  1253. end;
  1254. if literal or ((c<>'=') and (c<>'&')) then
  1255. with data[nrdata] do
  1256. if aname then name:=name+c else value:=value+c
  1257. else
  1258. begin
  1259. if c='&' then
  1260. begin
  1261. inc (nrdata);
  1262. aname:=true;
  1263. end
  1264. else
  1265. aname:=false;
  1266. end
  1267. end;
  1268. writeln ('<H1>Form Results :</H1>');
  1269. writeln ('You submitted the following name/value pairs :');
  1270. writeln ('<UL>');
  1271. for i:=1 to nrdata do writeln ('<LI> ',data[i].name,' = ',data[i].value);
  1272. writeln ('</UL>');
  1273. end.
  1274. \end{verbatim}
  1275. While this program isn't shorter than the C program provided as an example
  1276. at NCSA, it doesn't need any other units. everythig is done using standard
  1277. Pascal procedures\footnote{actually, this program will give faulty results,
  1278. since spaces in the input are converted to plus signs by the web browser.
  1279. The program doesn't check for this, but that is easy to change.
  1280. The main concern here is to give the working principle.}.
  1281. Note that this program has a limitation: the length of names and values is
  1282. limited to 255 characters. This is due to the fact that strings in Pascal
  1283. have a maximal length of 255. It is of course easy to redefine the
  1284. \var{datarec} record in such a way that longer values are allowed.
  1285. In case you have to read the contents of a \var{TEXTAREA} form element,
  1286. this may be needed.
  1287. % Data passed through an environment variable
  1288. \subsection{Data passed through an environment variable}
  1289. If your form uses the \var{GET} method of passing it's data, the CGI script
  1290. needs to read the \var{QUERY\_STRING} environment variable to get it's data.
  1291. Since this variable can, and probably will, be more than 255 characters long,
  1292. you will not be able to use normal string methods, present in pascal. \fpk
  1293. implements the \var{pchar} type, which is a pointer to a null-terminated
  1294. array of characters.
  1295. And, fortunately, \fpk has a
  1296. \seestrings\ unit, which eases the use of the
  1297. \var{pchar} type.
  1298. The following example illustrates what to do in case of a method of \var{GET}
  1299. \begin{verbatim}
  1300. program cgi_get;
  1301. uses strings,linux;
  1302. const max_data = 1000;
  1303. type datarec = record
  1304. name,value : string;
  1305. end;
  1306. var data : array[1..max_data] of datarec;
  1307. i,nrdata : longint;
  1308. p : PChar;
  1309. literal,aname : boolean;
  1310. begin
  1311. Writeln ('Content-type: text/html');
  1312. Writeln;
  1313. if StrComp(GetEnv('REQUEST_METHOD'),'POST')<>0 then
  1314. begin
  1315. Writeln ('This script should be referenced with a METHOD of GET');
  1316. write ('If you don''t understand this, see this ');
  1317. write ('< A HREF="http://www.ncsa.uiuc.edu/SDG/Softare/Mosaic');
  1318. Writeln ('/Docs/fill-out-forms/overview.html">forms overview</A>.');
  1319. halt(1);
  1320. end;
  1321. p:=GetEnv('QUERY_STRING');
  1322. nrdata:=1;
  1323. aname:=true;
  1324. while p^<>#0 do
  1325. begin
  1326. literal:=false;
  1327. if p^='\' then
  1328. begin
  1329. literal:=true;
  1330. inc(longint(p));
  1331. end;
  1332. if ((p^<>'=') and (p^<>'&')) or literal then
  1333. with data[nrdata] do
  1334. if aname then name:=name+p^ else value:=value+p^
  1335. else
  1336. begin
  1337. if p^='&' then
  1338. begin
  1339. inc (nrdata);
  1340. aname:=true;
  1341. end
  1342. else
  1343. aname:=false;
  1344. end;
  1345. inc(longint(p));
  1346. end;
  1347. Writeln ('<H1>Form Results :</H1>');
  1348. Writeln ('You submitted the following name/value pairs :');
  1349. Writeln ('<UL>');
  1350. for i:=1 to nrdata do writeln ('<LI> ',data[i].name,' = ',data[i].value);
  1351. Writeln ('</UL>');
  1352. end.
  1353. \end{verbatim}
  1354. Although it may not be written in the most elegant way, this program does
  1355. the same thing as the previous one. It also suffers from the same drawback,
  1356. namely the limited length of the \var{value} field of the \var{datarec}.
  1357. This drawback can be remedied by redefining \var{datarec} as follows:
  1358. \begin{verbatim}
  1359. type datarec = record;
  1360. name,value : pchar;
  1361. end;
  1362. \end{verbatim}
  1363. and assigning at run time enough space to keep the contents of the value
  1364. field. This can be done with a
  1365. \begin{verbatim}
  1366. getmem (data[nrdata].value,needed_number_of_bytes);
  1367. \end{verbatim}
  1368. call. After that you can do a
  1369. \begin{verbatim}
  1370. strlcopy (data[nrdata].value,p,needed_number_of_bytes);
  1371. \end{verbatim}
  1372. to copy the data into place.
  1373. You may have noticed the following unorthodox call :
  1374. \begin{verbatim}
  1375. inc(longint(p));
  1376. \end{verbatim}
  1377. \fpk doesn't give you pointer arithmetic as in C. However, \var{longints} and
  1378. \var{pointers} have the same length (namely 4 bytes). Doing a type-cast to a
  1379. \var{longint} allows you to do arithmetic on the \var{pointer}.
  1380. Note however, that this is a non-portable call. This may work on the I386
  1381. processor, but not on a ALPHA processor (where a pointer is 8 bytes long).
  1382. This will be remedied in future releases of \fpk.
  1383. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1384. % Producing output
  1385. \section{Producing output}
  1386. The previous section concentrated mostly on getting input from the web
  1387. server. To send the reply to the server, you don't need to do anything
  1388. special.You just print your data on standard output, and the Web-server will
  1389. intercept this, and send your output to the WWW-client waiting for it.
  1390. You can print anything you want, the only thing you must take care of is
  1391. that you supply a \var{Contents-type} line, followed by an empty line, as
  1392. follows:
  1393. \begin{verbatim}
  1394. Writeln ('Content-type: text/html');
  1395. Writeln;
  1396. { ...start output of the form... }
  1397. \end{verbatim}
  1398. And that's all there is to it !
  1399. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1400. % I'm under Windows, what now ?
  1401. \section{I'm under Windows, what now ?}
  1402. Under Windows the system of writing CGI scripts is totally different. If you
  1403. use \fpk under Windows then you also should be able to do CGI programming,
  1404. but the above instructions will not work.
  1405. If some kind soul is willing to write a section on CGI programming under
  1406. Windows, I'd be willing to include it here.
  1407. \appendix
  1408. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1409. % APPENDIX A.
  1410. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1411. \chapter{Alphabetical listing of command-line options}
  1412. The following is alphabetical listing of all command-line options, as
  1413. generated by the compiler:
  1414. \begin{verbatim}
  1415. PPC386 [options] <inputfile> [options]
  1416. + switch option on, - off
  1417. with * marked options have no effect
  1418. with ! marked options are only partial implemented
  1419. -a the compiler doesn't delete the generated assembler file
  1420. -B build
  1421. -C code generation options
  1422. * -Ca
  1423. * -Ce
  1424. -Chxxxx xxxx bytes heap
  1425. (must be less than 67107840 und greater than 1023
  1426. -Ci IO-checking
  1427. -Co check overflow of integer operations
  1428. -Cr range checking
  1429. -Csxxxx stack size (only OS/2)
  1430. -dxxx defines the symbol xxx
  1431. -D controlls the generation of DEF file (only OS/2)
  1432. -Ddxxxx xxxx is the description
  1433. -Do generate DEF file
  1434. -Dw PM application
  1435. -exxxx xxxx path to executables (only LINUX)
  1436. -g generate debugger informations
  1437. -F set file names and pathes
  1438. -Fexxxx redirect error output to xxxx
  1439. -Fgxxxx xxxxx search path for the GNU C lib (LINUX only)
  1440. -Frxxxx xxxxx search path for the error message file (only LINUX)
  1441. -L set language
  1442. -LD german
  1443. -LE english
  1444. -l write logo
  1445. -i information
  1446. -Ixxx adds xxx to include path
  1447. -n don't read the default config file
  1448. -oxxx change the name of the executable produced to xxx
  1449. -q- write information when compiling (obsolete, see -v)
  1450. -S syntax options
  1451. -S2 switch some Delphi 2 extension on
  1452. -Sa semantic check of expressions
  1453. a higher level includes the lower
  1454. -Sa0 only ANSI pascal expressions are allowed
  1455. -Sa1 functions results havn't to be assigned to variables
  1456. -Sa2 @-operator returns typed pointer
  1457. -Sa4 assigment results are typed (allows a:=b:=0)
  1458. -Sa9 allows expressions with no side effect
  1459. -Sc supports operators like C (*=,+=,/= and -=)
  1460. -Sg allows LABEL and GOTO
  1461. -Si support C++ stlyed INLINE
  1462. -Sm support macros like C (global)
  1463. -So tries to be TP/BP 7.0 compatible
  1464. -Ss the name of constructors must be init
  1465. the name of destructors must be done
  1466. -St allows static keyword in objects
  1467. -s don't call assembler and linker (only with -a)
  1468. -T target operating system
  1469. -TDOS DOS extender by DJ Delorie
  1470. -TOS2 OS/2 2.x
  1471. -TLINUX Linux
  1472. ! -TWin32 Windows 32 Bit
  1473. -TGO32V2 version 2 of DJ Delorie DOS extender
  1474. -uxxx undefines the symbol xxx
  1475. -U unit options
  1476. -Un don't check the unit name
  1477. -Us compile a system unit
  1478. -Upxxxx adds xxxx to the unit path
  1479. -vxxx Be verbose. xxx is a combination of the following letters :
  1480. e : Show errors (default) i : Show general info
  1481. w : Show warnings l : Show linenumbers
  1482. u : Show used files t : Show tried files
  1483. p : Show compiled procedures c : Show conditionals
  1484. d : Show debug info m : Show defined macros
  1485. -w- turns warnings off (Obsolete, see -v)
  1486. -X executable options
  1487. -Xc link with the c library
  1488. -Xe create ELF executable
  1489. Processor specific options:
  1490. -A output format
  1491. -Aatt AT&T assembler
  1492. -Ao coff file using GNU AS
  1493. -Aobj OMF file using NASM
  1494. -Anasm coff file using NASM
  1495. -Amasm assembler for the Microsoft/Borland/Watcom assembler
  1496. -R assembler reading style
  1497. -Ratt read AT&T style assembler
  1498. -Rintel read Intel style assembler
  1499. -Rdirect copy assembler text directly to assembler file
  1500. -O optimizations
  1501. -Oa simple optimizations
  1502. -Og optimize for size
  1503. -OG optimize for time
  1504. -Ox optimize maximum
  1505. -O2 optimize for Pentium II (tm)
  1506. -O3 optimize for i386
  1507. -O4 optimize for i486
  1508. -O5 optimize for Pentium (tm)
  1509. -O6 optimizations for PentiumPro (tm)
  1510. -h,-? shows this help
  1511. \end{verbatim}
  1512. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1513. % APPENDIX B.
  1514. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1515. \chapter{Alphabetical list of reserved words}
  1516. \label{ch:reserved}
  1517. \latex{\begin{multicols}{3}}% \texttt
  1518. \begin{verbatim}
  1519. absolute
  1520. abstract
  1521. and
  1522. array
  1523. as
  1524. asm
  1525. assembler
  1526. begin
  1527. break
  1528. case
  1529. class
  1530. const
  1531. constructor
  1532. continue
  1533. destructor
  1534. dispose
  1535. div
  1536. do
  1537. downto
  1538. else
  1539. end
  1540. except
  1541. exit
  1542. export
  1543. exports
  1544. external
  1545. fail
  1546. false
  1547. far
  1548. file
  1549. finally
  1550. for
  1551. forward
  1552. function
  1553. goto
  1554. if
  1555. implementation
  1556. in
  1557. inherited
  1558. initialization
  1559. inline
  1560. interface
  1561. interrupt
  1562. is
  1563. label
  1564. library
  1565. mod
  1566. name
  1567. near
  1568. new
  1569. nil
  1570. not
  1571. object
  1572. of
  1573. on
  1574. operator
  1575. or
  1576. otherwise
  1577. packed
  1578. private
  1579. procedure
  1580. program
  1581. property
  1582. protected
  1583. public
  1584. raise
  1585. record
  1586. repeat
  1587. self
  1588. set
  1589. shl
  1590. shr
  1591. string
  1592. then
  1593. to
  1594. true
  1595. try
  1596. type
  1597. unit
  1598. until
  1599. uses
  1600. var
  1601. virtual
  1602. while
  1603. with
  1604. xor
  1605. \end{verbatim}
  1606. \latex{\end{multicols}}
  1607. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1608. % APPENDIX C.
  1609. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1610. \chapter{Compiler error messages}
  1611. \begin{description}
  1612. \item [unexpected end of file]
  1613. this typically happens in on of the following cases :
  1614. \begin{itemize}
  1615. \item The source file ends befor then final \var{end.} statement. This
  1616. happens mostly when the \var{begin} and \var{end} statements aren't
  1617. balanced;
  1618. \item An include file ends in the middle of a statement.
  1619. \item A comment wasn't closed.
  1620. \end{itemize}
  1621. \item [duplicate identifier:]
  1622. The identifier was already declared in the current scope.
  1623. \item [syntax error:]
  1624. An error against the Turbo Pascal language was encountered. This happens
  1625. typically when an illegal character is found in the sources file.
  1626. \item [out of memory]
  1627. The compiler doesn't have enough memory to compile your program. There are
  1628. several remedies for this:
  1629. \begin{itemize}
  1630. \item If you're using the build option of the compiler, try compiling the
  1631. different units manually.
  1632. \item If you're compiling a huge program, split it up in units, and compile
  1633. these separately.
  1634. \item If the previous two don't work, recompile the compiler with a bigger
  1635. heap (you can use the \var{-Ch} option for this, \seeo{Ch})
  1636. \end{itemize}
  1637. \item [unknown identifier]
  1638. The identifier encountered hasn't been declared, or is used outside the
  1639. scope where it's defined.
  1640. \item [illegal character]
  1641. An illegal character was encountered in the input file.
  1642. \item [source too long]
  1643. The compiler cannot cope with source files longer than (???)
  1644. \item [INLINE not supported (use option -Si for C++ styled inlining)]
  1645. You tried to compile a program with C++ style inlining, and forgot to
  1646. specify the \var{-Si} option (\seeo{Si}). The compiler doesn't support C++
  1647. styled inlining by default.
  1648. \item [NEAR ignored]
  1649. This is a warning. \var{NEAR} is a construct for 8 or 16 bit programs. Since
  1650. the compile generates 32 bit programs, it ignores this directive.
  1651. \item [FAR ignored]
  1652. This is a warning. \var{FAR} is a construct for 8 or 16 bit programs. Since
  1653. the compile generates 32 bit programs, it ignores this directive.
  1654. \item [INTERRUPT ignored]
  1655. Interrupt procedures aren't possible on operating systems, other than DOS,
  1656. it isn't allowed to take over an interrupt at the user level. (versions
  1657. older than 0.9.2 didn't have \var{INTERRUPT} support.
  1658. \item [private methods can't be VIRTUAL]
  1659. You declared a method in the private part of a object (class) as
  1660. \var{virtual}. This is not allowed. Private methods cannot be overridden
  1661. anyway.
  1662. \item [constructor can't be private or protected]
  1663. Constructors must be in the 'public' part of an object (class) declaration.
  1664. \item [destructor can't be private or protected]
  1665. Destructors must be in the 'public' part of an object (class) declaration.
  1666. \item [identifier not found]
  1667. \item [local class definitions are not allowed]
  1668. Classes must be defined globally.
  1669. \item [anonym class definitions are not allowed]
  1670. \item [type identifier expected]
  1671. The identifier is not a type, or you forgot to supply a type identifier.
  1672. \item [identifier already as type identifier declared]
  1673. You are trying to redefine a type.
  1674. \item [type identifier not defined]
  1675. The compiler encountered an unknown type.
  1676. \item [type mismatch]
  1677. This can happen in many cases:
  1678. \begin{itemize}
  1679. \item The variable you're assigning to is of a different type than the
  1680. expression in the assignment.
  1681. \item You are calling a function or procedure with parameters that are
  1682. incompatible with the parameters in the function or procedure definition.
  1683. \end{itemize}
  1684. \item [statement expected]
  1685. \item [illegal integer constant]
  1686. \item [illegal expression]
  1687. \item [expression too complicated - FPU stack overflow]
  1688. Your expression is too long for the compiler. You should try dividing the
  1689. construct over multiple assignments.
  1690. \item [CONTINUE not possible]
  1691. You're trying to use \var{continue} outside a loop construction.
  1692. \item [BREAK not possible]
  1693. You're trying to use \var{break} outside a loop construction.
  1694. \item [exception handling needed to compile this (command line -Se)]
  1695. Older (less than 0.6.6) versions of \fpk only. Your statement needs exception handling.
  1696. Exception handling isn't supported by default in the compiler.
  1697. Use the \var{-Se} option to turn on exception handling.% (\seeo{Se})
  1698. \item [illegal qualifier]
  1699. One of the following is appending :
  1700. \begin{itemize}
  1701. \item You're trying to access a field of a variable that is not a record.
  1702. \item You're indexing a variable that is not an array.
  1703. \item You're dereferencing a variable that is not a pointer.
  1704. \end{itemize}
  1705. \item [illegal count variable] The type of a \var{for} loop must be ordinal.
  1706. \item [ordinal type expected]
  1707. The expression must be of ordinal type (i.e. maximum a Longint)
  1708. \item [high range limit < low range limit]
  1709. You are declaring a subrange, and the lower limit is higher than the high
  1710. limit of the range.
  1711. \item [illegal unit identifier]
  1712. The name of the unit doesn't match the file name.
  1713. \item [unknown format of unit file]
  1714. The unit the compiler is trying to read is corrupted, or generated with a
  1715. newer version of the compiler.
  1716. \item [error when reading unit]
  1717. The unit the compiler is trying to read is corrupted, or generated with a
  1718. newer version of the compiler.
  1719. \item [circular unit use]
  1720. Two units are using each other in the interface part. This is only allowed
  1721. in the implementation part.
  1722. \item [too many units]
  1723. \fpk has a limit of 1024 units in a program. You can change this behavior
  1724. by changing the \var{maxunits} constant in the \file{files.pas} file of the
  1725. compiler, and recompiling the compiler.
  1726. \item [illegal char constant]
  1727. \item [overloaded identifier isn't a function identifier]
  1728. \item [overloaded functions have the same parameter list]
  1729. You're declaring overloaded functions, but with the same parameter list.
  1730. Overloaded function must have at least 1 different parameter in their
  1731. declaration.
  1732. \item [illegal parameter list]
  1733. You are calling a function with parameters that are of a different type than
  1734. the declared parameters of the function.
  1735. \item [can't determine which overloaded function to call]
  1736. You're calling overloaded functions with a parameter that doesn't correspond
  1737. to any of the declared function parameter lists. e.g. when you have declared
  1738. a function with parameters \var{word} and \var{longint}, and then you call
  1739. it with a parameter which is of type \var{integer}.
  1740. \item [exception handling not used, however needed by function]
  1741. This message is no longer used.
  1742. \item [forward declaration not solved:]
  1743. This can happen in two cases:
  1744. \begin{itemize}
  1745. \item This happens when you declare a function (in the \var{interface} part, or
  1746. with a \var{forward} directive, but do not implement it.
  1747. \item You reference a type which isn't declared in the current \var{type}
  1748. block.
  1749. \end{itemize}
  1750. \item [input file not found]
  1751. \fpk cannot find the program or unit source file, or the included file isn't
  1752. found.
  1753. \item [function header doesn't match the forward declaration]
  1754. You declared the function in the \var{interface} part, or with the
  1755. \var{forward} directive, but define it with a different parameter list.
  1756. \item [unknown field identifier]
  1757. The field doesn't exist in the record definition.
  1758. \item [parameter list size exceeds 65535 bytes]
  1759. The I386 processor limits the parameter list to 65535 bytes (the \var{RET}
  1760. instruction causes this)
  1761. \item [function nesting > 31]
  1762. You can nest function definitions only 31 times.
  1763. \item [illegal compiler switch]
  1764. You included a compiler switch (i.e. \var{\{\$... \}}) which the compiler
  1765. doesn't know.
  1766. \item [can't open include file]
  1767. You want to include (i.e \var{\{\$i file\}}) which the compiler doesn't
  1768. find. Check if the filename is correct.
  1769. \item [record or class type expected]
  1770. The variable or expression isn't of the type \var{record} or \var{class}.
  1771. \item [not found:]
  1772. An unknown symbol was encountered.
  1773. \item [only values can be jumped over in enumeration types]
  1774. \fpk allows enumeration constructions as in C. Given the following
  1775. declaration two declarations:
  1776. \begin{verbatim}
  1777. type a = (A_A,A_B,A_E=:6,A_UAS:=200);
  1778. type a = (A_A,A_B,A_E=:6,A_UAS:=4);
  1779. \end{verbatim}
  1780. The second declaration would produce an error. \var{A\_UAS} needs to have a
  1781. value higher than \var{A\_E}, i.e. at least 7.
  1782. \item [pointer type expected]
  1783. The variable or expression isn't of the type \var{pointer}.
  1784. \item [unit is compiled for another operating system]
  1785. The unit was compiled with a different target than the target for which
  1786. you're compiling now. (see the option \var{-T} \seeo{T}).
  1787. \item [typed constants of classes are not allowed]
  1788. You cannot declare a constant of type class or object.
  1789. \item [duplicate case label]
  1790. You are specifying the same label 2 times in a \var{case} statement.
  1791. \item [range check error while Eva luting constants]
  1792. The constants are out of their allowed range.
  1793. \item [illegal type conversion]
  1794. When doing a type-cast, you must take care that the sizes of the variable and
  1795. the destination type are the same.
  1796. \item [class type expected]
  1797. The variable of expression isn't of the type \var{class}.
  1798. \item [functions variables of overloaded functions are not allowed]
  1799. You are trying to assign an overloaded function to a procedural variable.
  1800. This isn't allowed.
  1801. \item [can't open assembler output file]
  1802. The assembler output file cannot be opened. This can have many causes, but
  1803. 'disk full' is a reasonable guess.
  1804. \item [string length must be a value from 1 to 255]
  1805. The length of a string in Pascal is limited to 255 characters. You are
  1806. trying to declare a string with length greater than 255.
  1807. \item [class identifier expected]
  1808. The variable isn't of type \var{class}.
  1809. \item [method identifier expected]
  1810. This identifier is not a method.
  1811. \item [function header doesn't match any method of this class]
  1812. You are defining a function as a class method, but no such function was
  1813. declared in the class.
  1814. \item [use extended syntax of DISPOSE and NEW to generate instances of classes]
  1815. If you have a pointer \var{a} to a class type, then the statement
  1816. \var{new(a)} will not initialize the class (i.e. the constructor isn't
  1817. called), although space will be allocated. you should issue the
  1818. \var{new(a,init)} statement. This will allocate space, and call the
  1819. constructor of the class.
  1820. \item [file types must be var parameters]
  1821. You cannot specify files as value parameters, i.e. they must always be
  1822. declared \var{var} parameters.
  1823. \item [string constant exceeds line end]
  1824. You forgot probably to include the closing ' in a string.
  1825. \item [illegal version of the unit:]
  1826. This unit was compiled with an earlier version of \fpk.
  1827. \item [illegal floating point constant]
  1828. \item [destructors can't have parameters]
  1829. You are declaring a destructor with a parameter list. Destructor methods
  1830. cannot have parameters.
  1831. \item [FAIL can be used in constructors only]
  1832. You are using the \var{FAIl} instruction outside a constructor method.
  1833. \item [records fields can be aligned to 1,2 or 4 bytes only]
  1834. You are specifying the \var{\{\$PACKRECORDS n\} } with an illegal value for
  1835. \var{n}. Only 1,2 or 4 are valid in this case.
  1836. \item [too many \$ENDIFs or \$ELSEs]
  1837. Your \var{\{\$IFDEF ..\}} and {\{\$ENDIF\}} statements aren't balanced.
  1838. \item [\$ENDIF expected]
  1839. Your \var{\{\$IFDEF ..\}} and {\{\$ENDIF\}} statements aren't balanced.
  1840. \item [illegal call by reference parameters]
  1841. \item [can't generate DEF file]
  1842. \ostwo only. The DEF file cannot be generated.
  1843. \item [all overloaded methods must be virtual if one is virtual:]
  1844. If you declare overloaded methods in a class, then they should either all be
  1845. virtual, or none. You cannot mix them.
  1846. \item [overloaded methods which are virtual must have the same return type:]
  1847. If you declare virtual overloaded methods in a class definition, they must
  1848. have the same return type.
  1849. \item [all overloaded virtual methods must support exceptions if one support exceptions:]
  1850. If you declare overloaded virtual methods in a class, then they should either
  1851. all support exceptions, or none. You cannot mix them.
  1852. \item [EXPORT declared functions can't be called]
  1853. You are trying to call a procedure you declared as \var{export}. Due to the
  1854. different calling scheme of \fpk and C, you cannot call such a function from
  1855. within your Pascal program.
  1856. \item [EXPORT declared functions can't be nested]
  1857. You cannot declare a function or procedure within a function or procedure
  1858. that was declared as an export procedure.
  1859. \item [methods can't be EXPORTed]
  1860. You cannot declare a procedure that is a method for an object as
  1861. \var{export}ed. That is, you methods cannot be called from a C program.
  1862. \item [SELF is allowed in methods only]
  1863. You are trying to use the \var{self} parameter outside an object's method.
  1864. Only methods get passed the \var{self} parameters.
  1865. \item [call by var parameters have to match exactly]
  1866. When calling a function declared with \var{var} parameters, the variables in
  1867. the function call must be of exactly the same type. There is no automatic
  1868. type conversion.
  1869. \item [type identifiers are not allowed in this context]
  1870. \item [class identifier expected]
  1871. The variable isn't of type \var{class}.
  1872. \item [class isn't a super class of the current class]
  1873. When calling inherited methods, you are trying to call a method of a strange
  1874. class. You can only call an inherited method of a parent class.
  1875. \item [methods can be only in other methods called direct with type identifier of the class]
  1876. A construction like \var{sometype.somemethod} is only allowed in a method.
  1877. \item [illegal INHERITED: class has no super class]
  1878. You specified an \var{INHERITED} keyword in a method of a class which has no
  1879. parent class, i.e. which isn't derived from another class.
  1880. \item [illegal type: pointer to class expected]
  1881. You specified an illegal type.
  1882. \item [possible illegal call of constructor or destructor (doesn't match to this context)]
  1883. \item [class should have one destructor only]
  1884. You can declare only one destructor for a class.
  1885. \item [expression must be constructor call]
  1886. When using the extended syntax of \var{new}, you must specify the constructor
  1887. method of the class you are trying to create. The procedure you specified
  1888. is not a constructor.
  1889. \item [identifier idents no member]
  1890. When using the extended syntax of \var{new}, you must specify the constructor
  1891. method of the class you are trying to create. The procedure you specified
  1892. does not exist.
  1893. \item [expression must be destructor call]
  1894. When using the extended syntax of \var{dispose}, you must specify the
  1895. destructor method of the class you are trying to dispose of.
  1896. The procedure you specified is not a destructor.
  1897. \item [assembler: illegal constant]
  1898. \item [illegal type declaration of set elements]
  1899. \item [illegal expression in set constructor]
  1900. \item [type conflict between set elements]
  1901. You are specifying elements of a different type for a set.
  1902. \item [illegal use of ':']
  1903. \item [expression type must be class or record type]
  1904. The expression isn't of type class or record.
  1905. \item [the operator / isn't defined for integer, the result will be real, use DIV instead]
  1906. When using the '/' operator in \fpk the result will be of type real, when
  1907. used with integers.
  1908. \item [can't write PPU file]
  1909. There is a problem when writing to the unit file.
  1910. \item [illegal order of record elements]
  1911. When declaring a constant record, you specified the fields in the wrong
  1912. order.
  1913. \item [the name of constructors must be INIT]
  1914. You are declaring a constructor with a name which isn't \var{init}, and the
  1915. \var{-Ss} switch is in effect. See the \var{-Ss} switch (\seeo{Ss}).
  1916. \item [the name of constructors must be DONE]
  1917. You are declaring a constructor with a name which isn't \var{done}, and the
  1918. \var{-Ss} switch is in effect. See the \var{-Ss} switch (\seeo{Ss}).
  1919. \item [set element type mismatch]
  1920. The type of the element doesn't equal the set type.
  1921. \item [illegal label declaration]
  1922. \item [label not found]
  1923. A \var{goto label} was encountered, but the label isn't declared.
  1924. \item [GOTO and LABEL are not supported (use command line switch -Sg)]
  1925. You must compile a program which has \var{label}s and \var{goto} statements
  1926. with the \var{-Sg} switch. By default, \var{label} and \var{goto} aren't
  1927. supported.
  1928. \item [set expected]
  1929. The variable or expression isn't of type \var{set}.
  1930. \item [identifier isn't a label]
  1931. The identifier specified after the \var{goto} isn't of type label.
  1932. \item [label already defined]
  1933. You're attempting to define a label two times. (i.e. you put the same label
  1934. on two different places.)
  1935. \item [label isn't defined:]
  1936. A label was declared, but not defined.
  1937. \item [constructors and destructors must be methods]
  1938. You're declaring a procedure as destructor or constructor, when the
  1939. procedure isn't a class method.
  1940. \item [error when assembling]
  1941. An error occurred when assembling. This can have many causes.
  1942. \item [identifier not used:]
  1943. This is a warning. The identifier was declared (locally or globally) but
  1944. wasn't used (locally or globally).
  1945. \item [functions with void return value can't return any value]
  1946. In \fpk, you can specify a return value for a function when using
  1947. the \var{exit} statement. This error occurs when you try to do this with a
  1948. procedure. Procedures cannot return a value.
  1949. \item [Hmmm..., this code can't be much efficient]
  1950. You construction seems dubious to the compiler.
  1951. \item [unreachable code]
  1952. You specified a loop which will never be executed. Example:
  1953. \begin{verbatim}
  1954. while false do
  1955. begin
  1956. {.. code ...}
  1957. end;
  1958. \end{verbatim}
  1959. \item [This overloaded function can't be local (must be exported)]
  1960. You are defining a overloaded function in the implementation part of a unit,
  1961. but there is no corresponding declaration in the interface part of the unit.
  1962. \item [It's not possible to overload this operator]
  1963. You are trying to overload an operator which cannot be overloaded.
  1964. \item [Abstract methods can't be called direct]
  1965. \fpk understands the \var{abstract} keyword.
  1966. \item [the mix of CLASSES and OBJECTS are not allowed]
  1967. You cannot use \var{object} and \var{class} intertwined.
  1968. \item [macro buffer overflow while reading or expanding a macro]
  1969. Your macro or it's result was too long for the compiler.
  1970. \item [keyword redefined as macro has no effect]
  1971. You cannot redefine keywords with macros.
  1972. \item [extension of macros exceeds a deep of 16,\\ perhaps there is a recursive macro definition (crashes the compiler)]
  1973. When expanding a macro macros have been nested to a level of 16.
  1974. \item [ENDIF without IF(N)DEF]
  1975. Your code contains more \var{\{\$ENDIF\}} than \var{\{\$IF(N)DEF\}}
  1976. statements.
  1977. \item [user defined:]
  1978. A user defined warning occurred. see also the \progref
  1979. \item [linker: Duplicate symbol:]
  1980. Two global symbols in the code have the same name.
  1981. \item [linker: Error while reading object file]
  1982. The linker couldn't read the object file (the assembled file).
  1983. \item [linker: object file not found]
  1984. The linker didn't find the object file (the assembled file).
  1985. \item [linker: illegal magic number in file:]
  1986. The linker cannot determine the type of a file it wants to link in. The type
  1987. of a link file is specified using a magic number, which is some pre-defined
  1988. constant, unique for each system.
  1989. \item [The extended syntax of new or dispose isn't allowed for a class]
  1990. You cannot generate an instance of a class with the extended syntax of
  1991. \var{new}. The constructor must be used for that. For the same reason, you
  1992. cannot call \var{Dispose} to de-allocate an instance of a class, the
  1993. destructor must be used for that.
  1994. \item [To generate an instance of a class or an object with an abstract method isn't allowed]
  1995. You are trying to generate an instance of a class which has an abstract
  1996. method that wasn't overridden.
  1997. \item [Only virtual methods can be abstract]
  1998. You are declaring a method as abstract, when it isn't declared to be
  1999. virtual.
  2000. \item [Abstract methods shouldn't have any definition (with function body)]
  2001. Abstract methods can only be declared, you cannot implement them. They
  2002. should be overridden by a descendant class.
  2003. \item [can't call the assembler]
  2004. An error occurred when calling the assembler.
  2005. \item [can't call o2obj]
  2006. An error occurred when calling the \var{o} to \var{obj} conversion program.
  2007. \item [asm syntax error]
  2008. There is an error in the assembly language.
  2009. \item [register name expected]
  2010. There is an error in the assembly language. The assembler expected a
  2011. register and got something else.
  2012. \item [asm size mismatch]
  2013. There is an error in the assembly language. The sizes of operands and
  2014. registers don't match.
  2015. \item [no instr match,]
  2016. There is an error in the assembly language. An unknown instruction was
  2017. encountered.
  2018. \item [can't compile unit:]
  2019. When trying to do a build, the compiler cannot compile one of the units.
  2020. \item [Re-raise isn't possible there]
  2021. You are trying to raise an exception where it isn't allowed. You can only
  2022. raise exceptions in an \var{except} block.
  2023. \end{description}
  2024. \chapter{Run time errors}
  2025. The \fpk Run-tim library generates the following errors at run-time
  2026. \footnote{The \linux port will generate only a subset of these.}:
  2027. \begin{description}
  2028. \item [1 Invalid function number]
  2029. You tried to call a \dos function which doesn't exist.
  2030. \item [2 File not found]
  2031. You can get this error when you tried to do an operation on a file which
  2032. doesn't exist.
  2033. \item [3 Path not found]
  2034. You can get this error when you tried to do an operation on a file which
  2035. doesn't exist, or when you try to change to, or remove a directory that doesn't exist,
  2036. or try to make a subdirectory of a subdirectory that doesn't exist.
  2037. \item [4 Too many open files]
  2038. When attempting to open a file for reading or writing, you can get this
  2039. error when your program has too many open files.
  2040. \item [5 File access denied]
  2041. You don't have access to the specified file.
  2042. \item [6 Invalid file handle]
  2043. If this happens, the file variable you are using is trashed; it
  2044. indicates that your memory is corrupted.
  2045. \item [12 Invalid file access code]
  2046. This will happen if you do a reset or rewrite of a file when \var{FileMode}
  2047. is invalid.
  2048. \item [15 Invalid drive number]
  2049. The number given to the Getdir function specifies a non-existent disk.
  2050. \item [16 Cannot remove current directory]
  2051. You get this if you try to remove the current diirectory.
  2052. \item [17 Cannot rename across drives]
  2053. You cannot rename a file such that it would end up on another disk or
  2054. partition.
  2055. \item [100 Disk read error]
  2056. \dos only. An error occurred when reading from disk. Typically when you try
  2057. to read past the end of a file.
  2058. \item [101 Disk write error]
  2059. \dos only. Reported when the disk is full, and you're trying to write to it.
  2060. \item [102 File not assigned]
  2061. This is reported by Reset, Rewrite, Append, Rename and Erase, if you call
  2062. them with an unassigne function as a parameter.
  2063. \item [103 File not open]
  2064. Reported by the following functions : Close , Read, Write, Seek,
  2065. EOf, FilePos, FileSize, Flush, BlockRead, and BlockWrite if the file isn't
  2066. open.
  2067. \item [104 File not open for input]
  2068. Reported by Read, BlockRead, Eof, Eoln, SeekEof or SeekEoln if the file
  2069. isn't opened with Reset.
  2070. \item [105 File not open for output]
  2071. Reported by write if a text file isn't opened with Rewrite.
  2072. \item [106 Invalid numeric format]
  2073. Reported when a non-numerice value is read from a text file, when a numeric
  2074. value was expected.
  2075. \item [150 Disk is write-protected]
  2076. (Critical error, \dos only.)
  2077. \item [151 Bad drive request struct length]
  2078. (Critical error, \dos only.)
  2079. \item [152 Drive not ready]
  2080. (Critical error, \dos only.)
  2081. \item [154 CRC error in data]
  2082. (Critical error, \dos only.)
  2083. \item [156 Disk seek error]
  2084. (Critical error, \dos only.)
  2085. \item [157 Unknown media type]
  2086. (Critical error, \dos only.)
  2087. \item [158 Sector Not Found]
  2088. (Critical error, \dos only.)
  2089. \item [159 Printer out of paper]
  2090. (Critical error, \dos only.)
  2091. \item [160 Device write fault]
  2092. (Critical error, \dos only.)
  2093. \item [161 Device read fault]
  2094. (Critical error, \dos only.)
  2095. \item [162 Hardware failure]
  2096. (Critical error, \dos only.)
  2097. \item [200 Division by zero]
  2098. You are dividing a number by zero.
  2099. \item [201 Range check error]
  2100. If you compiled your program with range checking on, then you can get this
  2101. error in the following cases:
  2102. \begin{enumerate}
  2103. \item An array was accessed with an index outside its declared range.
  2104. \item You're trying to assign a value to a variable outside its range (for
  2105. instance a enumerated type).
  2106. \end{enumerate}
  2107. \item [202 Stack overflow error]
  2108. The stack has grown beyond itss maximum size. This error can easily occur if
  2109. you have recursive functions.
  2110. \item [203 Heap overflow error]
  2111. The heap has grown beyond its boundaries, ad you are rying to get more
  2112. memory. Please note that \fpk provides a growing heap, i.e. the heap will
  2113. try to allocate more memory if needed. However, if the heap has reached the
  2114. maximum size allowed by the operating system or hardware, then you will get
  2115. this error.
  2116. \item [204 Invalid pointer operation]
  2117. This you will get if you call dispose or Freemem with an invalid pointer
  2118. (notably, \var{Nil})
  2119. \item [205 Floating point overflow]
  2120. You are trying to use or produce too large real numbers.
  2121. \item [206 Floating point underflow]
  2122. You are trying to use or produce too small real numbers.
  2123. \item [207 Invalid floating point operation]
  2124. Can occur if you try to calculate the square root or logarithm of a negative
  2125. number.
  2126. \item [210 Object not initialized]
  2127. When compiled with range checking on, a program will report this error if
  2128. you call a virtal method without having initialized the VMT.
  2129. \item [211 Call to abstract method]
  2130. Your program tried to execute an abstract virtual method. Abstract methods
  2131. should be overridden, and the overriding method should be called.
  2132. \item [212 Stream registration error]
  2133. This occurs when an invalid type is registered in the objects unit.
  2134. \item [213 Collection index out of range]
  2135. You are trying to access a collection item with an invalid index.
  2136. (objects unit)
  2137. \item [214 Collection overflow error]
  2138. The collection has reached its maximal size, and you are trying to add
  2139. another element. (objects unit)
  2140. \item [216 General Protection fault]
  2141. You are trying to access memory outside your appointed memory.
  2142. \end{description}
  2143. \end{document}