dos.tex 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869
  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. \chapter{The DOS unit.}
  22. \FPCexampledir{dosex}
  23. This chapter describes the \var{DOS} unit for Free pascal, both under
  24. \dos, \ostwo, \windows and \linux.
  25. The unit was first written for \dos by Florian kl\"ampfl. It was ported to
  26. \linux by Mark May\footnote{Current e-mail address \textsf{[email protected]}},
  27. and enhanced by Micha\"el Van Canneyt.
  28. Under non-\dos systems, some of the functionality is lost, as it is either impossible
  29. or meaningless to implement it. Other than that, the functionality for all
  30. operating systems is the same.
  31. This chapter is divided in two sections:
  32. \begin{itemize}
  33. \item The first section lists the pre-defined constants, types and variables.
  34. \item The second section describes the functions which appear in the
  35. interface part of the DOS unit.
  36. \end{itemize}
  37. \section{Types, Variables, Constants}
  38. \subsection {Constants}
  39. The DOS unit implements the following constants:
  40. \begin{verbatim}
  41. {Bitmasks for CPU Flags}
  42. fcarry = $0001;
  43. fparity = $0004;
  44. fauxiliary = $0010;
  45. fzero = $0040;
  46. fsign = $0080;
  47. foverflow = $0800;
  48. {Bitmasks for file attribute}
  49. readonly = $01;
  50. hidden = $02;
  51. sysfile = $04;
  52. volumeid = $08;
  53. directory = $10;
  54. archive = $20;
  55. anyfile = $3F;
  56. fmclosed = $D7B0;
  57. fminput = $D7B1;
  58. fmoutput = $D7B2;
  59. fminout = $D7B3;
  60. \end{verbatim}
  61. \subsection{Types}
  62. The following string types are defined for easy handling of
  63. filenames :
  64. \begin{verbatim}
  65. ComStr = String[255]; { For command-lines }
  66. PathStr = String[255]; { For full path for file names }
  67. DirStr = String[255]; { For Directory and (DOS) drive string }
  68. NameStr = String[255]; { For Name of file }
  69. ExtStr = String[255]; { For Extension of file }
  70. \end{verbatim}
  71. \begin{verbatim}
  72. SearchRec = Packed Record
  73. Fill : array[1..21] of byte;
  74. { Fill replaced with declarations below, for Linux}
  75. Attr : Byte; {attribute of found file}
  76. Time : LongInt; {last modify date of found file}
  77. Size : LongInt; {file size of found file}
  78. Reserved : Word; {future use}
  79. Name : String[255]; {name of found file}
  80. SearchSpec: String[255]; {search pattern}
  81. NamePos: Word; {end of path, start of name position}
  82. End;
  83. \end{verbatim}
  84. Under \linux, the \var{Fill} array is replaced with the following:
  85. \begin{verbatim}
  86. SearchNum: LongInt; {to track which search this is}
  87. SearchPos: LongInt; {directory position}
  88. DirPtr: LongInt; {directory pointer for reading directory}
  89. SearchType: Byte; {0=normal, 1=open will close}
  90. SearchAttr: Byte; {attribute we are searching for}
  91. Fill: Array[1..07] of Byte; {future use}
  92. \end{verbatim}
  93. This is because the searching meachanism on Unix systems is substantially
  94. different from \dos's, and the calls have to be mimicked.
  95. \begin{verbatim}
  96. const
  97. filerecnamelength = 255;
  98. type
  99. FileRec = Packed Record
  100. Handle,
  101. Mode,
  102. RecSize : longint;
  103. _private : array[1..32] of byte;
  104. UserData : array[1..16] of byte;
  105. name : array[0..filerecnamelength] of char;
  106. End;
  107. \end{verbatim}
  108. \var{FileRec} is used for internal representation of typed and untyped files.
  109. Text files are handled by the following types :
  110. \begin{verbatim}
  111. const
  112. TextRecNameLength = 256;
  113. TextRecBufSize = 256;
  114. type
  115. TextBuf = array[0..TextRecBufSize-1] of char;
  116. TextRec = Packed Record
  117. Handle,
  118. Mode,
  119. bufsize,
  120. _private,
  121. bufpos,
  122. bufend : longint;
  123. bufptr : ^textbuf;
  124. openfunc,
  125. inoutfunc,
  126. flushfunc,
  127. closefunc : pointer;
  128. UserData : array[1..16] of byte;
  129. name : array[0..textrecnamelength-1] of char;
  130. buffer : textbuf;
  131. End;
  132. \end{verbatim}
  133. Remark that this is not binary compatible with the Turbo Pascal definition
  134. of \var{TextRec}, since the sizes of the different fields are different.
  135. \begin{verbatim}
  136. Registers = record
  137. case i : integer of
  138. 0 : (ax,f1,bx,f2,cx,f3,dx,f4,bp,f5,si,
  139. f51,di,f6,ds,f7,es,f8,flags,fs,gs : word);
  140. 1 : (al,ah,f9,f10,bl,bh,f11,f12,
  141. cl,ch,f13,f14,dl,dh : byte);
  142. 2 : (eax, ebx, ecx, edx, ebp, esi, edi : longint);
  143. End;
  144. \end{verbatim}
  145. The \var{registers} type is used in the \var{MSDos} call.
  146. \begin{verbatim}
  147. DateTime = record
  148. Year: Word;
  149. Month: Word;
  150. Day: Word;
  151. Hour: Word;
  152. Min: Word;
  153. Sec: word;
  154. End;
  155. \end{verbatim}
  156. The \var{DateTime} type is used in \seep{PackTime} and \seep{UnPackTime} for
  157. setting/reading file times with \seep{GetFTime} and \seep{SetFTime}.
  158. \subsection{Variables}
  159. \begin{verbatim}
  160. DosError : integer;
  161. \end{verbatim}
  162. The \var{DosError} variable is used by the procedures in the \dos unit to
  163. report errors. It can have the following values :
  164. \begin{center}
  165. \begin{tabular}{cl}
  166. 2 & File not found. \\
  167. 3 & path not found. \\
  168. 5 & Access denied. \\
  169. 6 & Invalid handle. \\
  170. 8 & Not enough memory. \\
  171. 10 & Invalid environment. \\
  172. 11 & Invalid format. \\
  173. 18 & No more files.
  174. \end{tabular}
  175. \end{center}
  176. Other values are possible, but are not documented.
  177. %\begin{verbatim}
  178. % drivestr : array [0..26] of pchar;
  179. %\end{verbatim}
  180. %This variable is defined in the \linux version of the \dos unit. It is used
  181. %in the \seef{DiskFree} and \seef{DiskSize} calls.
  182. \section{Functions and Procedures}
  183. \begin{procedure}{AddDisk}
  184. \Declaration
  185. Procedure AddDisk (Const S : String);
  186. \Description
  187. \var{AddDisk} adds a filename \var{S} to the internal list of disks. It is
  188. implemented for \linux only.
  189. This list is used to determine which disks to use in the \seef{DiskFree}
  190. and \seef{DiskSize} calls.
  191. The \seef{DiskFree} and \seef{DiskSize} functions need a file on the
  192. specified drive, since this is required for the \var{statfs} system call.
  193. The names are added sequentially. The dos
  194. initialization code presets the first three disks to:
  195. \begin{itemize}
  196. \item \var{'.'} for the current drive,
  197. \item \var{'/fd0/.'} for the first floppy-drive.
  198. \item \var{'/fd1/.'} for the second floppy-drive.
  199. \item \var{'/'} for the first hard disk.
  200. \end{itemize}
  201. The first call to \var{AddDisk} will therefore add a name for the second
  202. harddisk, The second call for the third drive, and so on until 23 drives
  203. have been added (corresponding to drives \var{'D:'} to \var{'Z:'})
  204. \Errors
  205. None
  206. \SeeAlso
  207. \seef{DiskFree}, \seef{DiskSize}
  208. \end{procedure}
  209. \begin{function}{DiskFree}
  210. \Declaration
  211. Function DiskFree (Drive: byte) : Int64;
  212. \Description
  213. \var{DiskFree} returns the number of free bytes on a disk. The parameter
  214. \var{Drive} indicates which disk should be checked. This parameter is 1 for
  215. floppy \var{a:}, 2 for floppy \var{b:}, etc. A value of 0 returns the free
  216. space on the current drive.
  217. Typically, the free space is the size of a disk block, multiplied by the
  218. number of free blocks on the disk.
  219. \textbf{For \linux only:}\\
  220. The \var{diskfree} and \var{disksize} functions need a file on the
  221. specified drive, since this is required for the \var{statfs} system call.
  222. These filenames are set in the initialization of the dos unit, and have
  223. been preset to :
  224. \begin{itemize}
  225. \item \var{'.'} for the current drive,
  226. \item \var{'/fd0/.'} for the first floppy-drive.
  227. \item \var{'/fd1/.'} for the second floppy-drive.
  228. \item \var{'/'} for the first hard disk.
  229. \end{itemize}
  230. There is room for 1-26 drives. You can add a drive with the
  231. \seep{AddDisk} procedure.
  232. These settings can be coded in \var{dos.pp}, in the initialization part.
  233. \Errors
  234. -1 when a failure occurs, or an invalid \var{drivenr} is given.
  235. \SeeAlso
  236. \seef{DiskSize}, \seep{AddDisk}
  237. \end{function}
  238. \FPCexample{ex6}
  239. \begin{function}{DiskSize}
  240. \Declaration
  241. Function DiskSize (Drive: byte) : Int64;
  242. \Description
  243. \var{DiskSize} returns the total size (in bytes) of a disk. The parameter
  244. \var{Drive} indicates which disk should be checked. This parameter is 1 for
  245. floppy \var{a:}, 2 for floppy \var{b:}, etc. A value of 0 returns the size
  246. of the current drive.
  247. \textbf{For \linux only:}\\
  248. The \var{diskfree} and \var{disksize} functions need a file on the specified drive, since this
  249. is required for the \var{statfs} system call.
  250. These filenames are set in the initialization of the dos unit, and have
  251. been preset to :
  252. \begin{itemize}
  253. \item \var{'.'} for the current drive,
  254. \item \var{'/fd0/.'} for the first floppy-drive.
  255. \item \var{'/fd1/.'} for the second floppy-drive.
  256. \item \var{'/'} for the first hard disk.
  257. \end{itemize}
  258. There is room for 1-26 drives. You can add a drive with the
  259. \seep{AddDisk} procedure.
  260. These settings can be coded in \var{dos.pp}, in the initialization part.
  261. \Errors
  262. -1 when a failure occurs, or an invalid drive number is given.
  263. \SeeAlso
  264. \seef{DiskFree}, \seep{AddDisk}
  265. \end{function}
  266. For an example, see \seef{DiskFree}.
  267. \begin{function}{DosExitCode}
  268. \Declaration
  269. Function DosExitCode : Word;
  270. \Description
  271. \var{DosExitCode} contains (in the low byte) the exit-code of a program
  272. executed with the \var{Exec} call.
  273. \Errors
  274. None.
  275. \SeeAlso
  276. \seep{Exec}
  277. \end{function}
  278. \FPCexample{ex5}
  279. \begin{function}{DosVersion}
  280. \Declaration
  281. Function DosVersion : Word;
  282. \Description
  283. \var{DosVersion} returns the \dos version number. On \linux systems, it
  284. returns the Linux version (The first 2 numbers, e.g Linux version 2.1.76 will
  285. give you DosVersion 2.1)
  286. \Errors
  287. None.
  288. \SeeAlso
  289. \end{function}
  290. \FPCexample{ex1}
  291. \begin{function}{EnvCount}
  292. \Declaration
  293. Function EnvCount : longint;\Description
  294. \var{EnvCount} returns the number of environment variables.
  295. \Errors
  296. None.
  297. \SeeAlso
  298. \seef{EnvStr}, \seef{Dos:GetEnv}
  299. \end{function}
  300. \begin{function}{EnvStr}
  301. \Declaration
  302. Function EnvStr (Index: integer) : string;\Description
  303. \var{EnvStr} returns the \var{Index}-th \var{Name=Value} pair from the list
  304. of environment variables.
  305. The index of the first pair is zero.
  306. \Errors
  307. The length is limited to 255 characters. This may cause problems under
  308. \linux. The \linux unit solves this problem.
  309. \SeeAlso
  310. \seef{EnvCount}, \seef{Dos:GetEnv}
  311. \end{function}
  312. \FPCexample{ex13}
  313. \begin{procedure}{Exec}
  314. \Declaration
  315. Procedure Exec (const Path: pathstr; const ComLine: comstr);
  316. \Description
  317. \var{Exec} executes the program in \var{Path}, with the options given by
  318. \var{ComLine}.
  319. After the program has terminated, the procedure returns. The Exit value of
  320. the program can be consulted with the \var{DosExitCode} function.
  321. \Errors
  322. Errors are reported in \var{DosError}.
  323. \SeeAlso
  324. \seef{DosExitCode}
  325. \end{procedure}
  326. For an example, see \seef{DosExitCode}
  327. \begin{functionl}{FExpand}{Dos:FExpand}
  328. \Declaration
  329. Function FExpand (const path: pathstr) : pathstr;
  330. \Description
  331. \var{FExpand} takes its argument and expands it to a complete filename, i.e.
  332. a filename starting from the root directory of the current drive, prepended
  333. with the drive-letter (under \dos).
  334. The resulting name is converted to uppercase on \dos systems. Under \linux,
  335. the name is left as it is. (filenames are case sensitive under Unix)
  336. \Errors
  337. \seep{FSplit}
  338. \SeeAlso
  339. \lstinputlisting{dosex/ex5.pp}
  340. \end{functionl}
  341. \begin{procedure}{FindClose}
  342. \Declaration
  343. Procedure FindClose (Var F: SearchRec);
  344. \Description
  345. \textbf{\linux, \windows and \ostwo wonly}
  346. \var{FindClose} frees any resources associated with the search record
  347. \var{F}.
  348. Under \linux, \windows and \ostwo the \var{findfirst/findnext} calls have
  349. to be mimicked. This call is needed to free any internal resources allocated
  350. by the \seef{FindFirst} or \seef{FindNext} calls.
  351. E.g. on \linux, an internal table of file descriptors is kept.
  352. When using different \var{searchrecs} at the same time,
  353. the system may run out of file descriptors for directories.
  354. The \linux implementation of the \dos unit therefore keeps a table of open
  355. directories, and when the table is full, closes one of the directories, and
  356. reopens another. This system is adequate but slow if you use a lot of
  357. \var{searchrecs}.
  358. So, to speed up the findfirst/findnext system, the \var{FindClose} call was
  359. implemented. When you don't need a \var{searchrec} any more, you can tell
  360. this to the \dos unit by issuing a \var{FindClose} call. The directory
  361. which is kept open for this \var{searchrec} is then closed, and the table slot
  362. freed.
  363. It is recommended to use the \linux call \var{Glob} when looking for files
  364. on \linux.
  365. \Errors
  366. None.
  367. \SeeAlso
  368. \seef{Glob}.
  369. \end{procedure}
  370. \begin{procedure}{FindFirst}
  371. \Declaration
  372. Procedure FindFirst (const Path: pathstr; Attr: word; var F: SearchRec);
  373. \Description
  374. \var{FindFirst} searches the file specified in \var{Path}, checks the
  375. atrributes specified in \var{Attr}. It returns a \var{SearchRec} record for
  376. further searching in \var{F}.
  377. \var{Path} can contain the wildcard characters \var{?} (matches any single
  378. character) and \var{*} (matches 0 ore more arbitrary characters). In this
  379. case \var{FindFirst} will return the first file which matches the specified
  380. criteria.
  381. If \var{DosError} is different from zero, no file(s) matching the criteria
  382. was(were) found.
  383. On \ostwo, you cannot issue two different \var{FindFirst} calls. That is,
  384. you must close any previous search operation with \seep{FindClose} before
  385. starting a new one. Failure to do so will end in a Run-Time Error 6
  386. (Invalid file handle)
  387. Also, on \ostwo, the boolean variable \var{FileNameCaseSensitive} indicates
  388. whether searches are conducted case-sensitive or not. By default, searches
  389. are not case sensitive. If the varieble is set to \var{True}, searches on
  390. \ostwo are case sensistive.
  391. \Errors
  392. Errors are reported in DosError.
  393. \SeeAlso
  394. \seep{FindNext},
  395. \seep{FindClose}
  396. \end{procedure}
  397. \FPCexample{ex7}
  398. \begin{procedure}{FindNext}
  399. \Declaration
  400. Procedure FindNext (var f: searchRec);
  401. \Description
  402. \var{FindNext} takes as an argument a \var{SearchRec} from a previous
  403. \var{FindNext} call, or a \var{FindFirst} call, and tries to find another
  404. file which matches the criteria, specified in the \var{FindFirst} call.
  405. If \var{DosError} is different from zero, no more files matching the
  406. criteria were found.
  407. \Errors
  408. \var{DosError} is used to report errors.
  409. \SeeAlso
  410. \seep{FindFirst}, \seep{FindClose}
  411. \end{procedure}
  412. For an example, see \seep{FindFirst}.
  413. \begin{functionl}{FSearch}{Dos:FSearch}
  414. \Declaration
  415. Function FSearch (Path: pathstr; DirList: string) : pathstr;
  416. \Description
  417. \var{FSearch} searches the file \var{Path} in all directories listed in
  418. \var{DirList}. The full name of the found file is returned.
  419. \var{DirList} must be a list of directories, separated by semi-colons (or
  420. colons under \linux).
  421. When no file is found, an empty string is returned.
  422. \Errors
  423. None.
  424. \SeeAlso
  425. \seefl{FExpand}{Dos:FExpand}
  426. \end{functionl}
  427. \FPCexample{ex10}
  428. \begin{procedure}{FSplit}
  429. \Declaration
  430. Procedure FSplit (path: pathstr; \\ var dir: dirstr; var name: namestr;
  431. var ext: extstr);
  432. \Description
  433. \var{FSplit} splits a full file name into 3 parts : A \var{Path}, a
  434. \var{Name} and an extension (in \var{ext}.)
  435. Under \linux, the extension is taken to be all letters after the last dot
  436. (.).
  437. \Errors
  438. None.
  439. \SeeAlso
  440. \seefl{FSearch}{Dos:FSearch}
  441. \end{procedure}
  442. \FPCexample{ex12}
  443. \begin{procedure}{GetCBreak}
  444. \Declaration
  445. Procedure GetCBreak (var breakvalue: boolean);
  446. \Description
  447. \var{GetCBreak} gets the status of CTRL-Break checking under \dos.
  448. When \var{BreakValue} is \var{false}, then \dos only checks for the
  449. CTRL-Break key-press when I/O is performed. When it is set to \var{True},
  450. then a check is done at every system call.
  451. \Errors
  452. Under Linux, this exists but is
  453. not implemented, i.e. the call does nothing.
  454. \SeeAlso
  455. \seep{SetCBreak}
  456. \end{procedure}
  457. \begin{procedurel}{GetDate}{Dos:GetDate}
  458. \Declaration
  459. Procedure GetDate (var year, month, mday, wday: word);\Description
  460. \var{GetDate} returns the system's date. \var{Year} is a number in the range
  461. 1980..2099.\var{mday} is the day of the month,
  462. \var{wday} is the day of the week, starting with Sunday as day 0.
  463. \Errors
  464. None.
  465. \SeeAlso
  466. \seepl{GetTime}{Dos:GetTime},\seep{SetDate}
  467. \end{procedurel}
  468. \FPCexample{ex2}
  469. \begin{functionl}{GetEnv}{Dos:GetEnv}
  470. \Declaration
  471. Function GetEnv (EnvVar: String) : String;
  472. \Description
  473. \var{Getenv} returns the value of the environment variable \var{EnvVar}.
  474. Under \linux, case is important when looking for \var{EnvVar}.
  475. When there is no environment variable \var{EnvVar} defined, an empty
  476. string is returned.
  477. \Errors
  478. None.
  479. \SeeAlso
  480. \seef{EnvCount}, \seef{EnvStr}
  481. \end{functionl}
  482. \FPCexample{ex14}
  483. \begin{procedure}{GetFAttr}
  484. \Declaration
  485. Procedure GetFAttr (var F; var Attr: word);
  486. \Description
  487. \var{GetFAttr} returns the file attributes of the file-variable \var{f}.
  488. \var{F} can be a untyped or typed file, or of type \var{Text}. \var{f} must
  489. have been assigned, but not opened. The attributes can be examined with the
  490. following constants :
  491. \begin{itemize}
  492. \item \var{ReadOnly = 01h}
  493. \item \var{Hidden = 02h}
  494. \item \var{SysFile = 04h}
  495. \item \var{VolumeId = 08h}
  496. \item \var{Directory = 10h}
  497. \item \var{Archive = 20h}
  498. \end{itemize}
  499. Under \linux, supported attributes are:
  500. \begin{itemize}
  501. \item \var{Directory}
  502. \item \var{ReadOnly} if the current process doesn't have access to the file.
  503. \item \var{Hidden} for files whose name starts with a dot \var{('.')}.
  504. \end{itemize}
  505. \Errors
  506. Errors are reported in \var{DosError}
  507. \SeeAlso
  508. \seep{SetFAttr}
  509. \end{procedure}
  510. \FPCexample{ex8}
  511. \begin{procedure}{GetFTime}
  512. \Declaration
  513. Procedure GetFTime (var F; var Time: longint);
  514. \Description
  515. \var{GetFTime} returns the modification time of a file.
  516. This time is encoded and must be decoded with \var{UnPackTime}.
  517. \var{F} must be a file type, which has been assigned, and
  518. opened.
  519. \Errors
  520. Errors are reported in \var{DosError}
  521. \SeeAlso
  522. \seep{SetFTime}, \seep{PackTime},\seep{UnPackTime}
  523. \end{procedure}
  524. \FPCexample{ex9}
  525. \begin{procedure}{GetIntVec}
  526. \Declaration
  527. Procedure GetIntVec (IntNo: byte; var Vector: pointer);
  528. \Description
  529. \var{GetIntVec} returns the address of interrupt vector
  530. \var{IntNo}.
  531. \Errors
  532. Under non- \dos operating systems, this call does nothing.
  533. \SeeAlso
  534. \seep{SetIntVec}
  535. \end{procedure}
  536. \begin{function}{GetLongName}
  537. \Declaration
  538. function GetLongName(var p : String) : boolean;\Description
  539. This function is only implemented in the GO32V2 version of \fpc.
  540. \var{GetLongName} changes the filename \var{p} to a long filename
  541. if the \dos call to do this is successful. The resulting string
  542. is the long file name corresponding to the short filename \var{p}.
  543. The function returns \var{True} if the \dos call was successful,
  544. \var{False} otherwise.
  545. This function should only be necessary when using the DOS extender
  546. under Windows 95 and higher.
  547. \Errors
  548. If the \dos call was not succesfull, \var{False} is returned.
  549. \SeeAlso
  550. \seef{GetShortName}
  551. \end{function}
  552. \begin{function}{GetShortName}
  553. \Declaration
  554. function GetShortName(var p : String) : boolean;\Description
  555. This function is only implemented in the GO32V2 version of \fpc.
  556. \var{GetShortName} changes the filename \var{p} to a short filename
  557. if the \dos call to do this is successful. The resulting string
  558. is the short file name corresponding to the long filename \var{p}.
  559. The function returns \var{True} if the \dos call was successful,
  560. \var{False} otherwise.
  561. This function should only be necessary when using the DOS extender
  562. under Windows 95 and higher.
  563. \Errors
  564. If the \dos call was not successful, \var{False} is returned.
  565. \SeeAlso
  566. \seef{GetLongName}
  567. \end{function}
  568. \begin{procedurel}{GetTime}{Dos:GetTime}
  569. \Declaration
  570. Procedure GetTime (var hour, minute, second, sec100: word);
  571. \Description
  572. \var{GetTime} returns the system's time. \var{Hour} is a on a 24-hour time
  573. scale. \var{sec100} is in hundredth of a
  574. second.
  575. \Errors
  576. None.
  577. \SeeAlso
  578. \seepl{GetDate}{Dos:GetDate},
  579. \seep{SetTime}
  580. \end{procedurel}
  581. \FPCexample{ex3}
  582. \begin{procedure}{GetVerify}
  583. \Declaration
  584. Procedure GetVerify (var verify: boolean);
  585. \Description
  586. \var{GetVerify} returns the status of the verify flag under \dos. When
  587. \var{Verify} is \var{True}, then \dos checks data which are written to disk,
  588. by reading them after writing. If \var{Verify} is \var{False}, then data
  589. written to disk are not verified.
  590. \Errors
  591. Under \linux, Verify is always
  592. \var{True}.
  593. \SeeAlso
  594. \seep{SetVerify}
  595. \end{procedure}
  596. \begin{procedure}{Intr}
  597. \Declaration
  598. Procedure Intr (IntNo: byte; var Regs: registers);
  599. \Description
  600. \var{Intr} executes a software interrupt number \var{IntNo} (must be between
  601. 0 and 255), with processor registers set to \var{Regs}. After the interrupt call
  602. returned, the processor registers are saved in \var{Regs}.
  603. \Errors
  604. Under \linux this call does nothing, because interrupts are managed by the
  605. kernel. The only allowed interrupt is 80h, the Linux kernel entry interrupt.
  606. \SeeAlso
  607. \seep{MSDos}, see the \linux unit.
  608. \end{procedure}
  609. \begin{procedure}{Keep}
  610. \Declaration
  611. Procedure Keep (ExitCode: word);
  612. \Description
  613. \var{Keep} terminates the program, but stays in memory. This is used for TSR
  614. (Terminate Stay Resident) programs which catch some interrupt.
  615. \var{ExitCode} is the same parameter as the \var{Halt} function takes.
  616. \Errors
  617. Under non-\dos operating systems, this call does nothing.
  618. \SeeAlso
  619. \seem{Halt}{}
  620. \end{procedure}
  621. \begin{procedure}{MSDos}
  622. \Declaration
  623. Procedure MSDos (var regs: registers);
  624. \Description
  625. \var{MSDos} executes an MS-\dos call (int 21h). This is the same as doing a
  626. \var{Intr} call with an interrupt number of 21h.
  627. \Errors
  628. None.
  629. \SeeAlso
  630. \seep{Intr}
  631. \end{procedure}
  632. \begin{procedure}{PackTime}
  633. \Declaration
  634. Procedure PackTime (var T: datetime; var P: longint);
  635. \Description
  636. \var{UnPackTime} converts the date and time specified in \var{T}
  637. to a packed-time format which can be fed to \var{SetFTime}.
  638. \Errors
  639. None.
  640. \SeeAlso
  641. \seep{SetFTime}, \seep{FindFirst}, \seep{FindNext}, \seep{UnPackTime}
  642. \end{procedure}
  643. \FPCexample{ex4}
  644. \begin{procedure}{SetCBreak}
  645. \Declaration
  646. Procedure SetCBreak (breakvalue: boolean);
  647. \Description
  648. \var{SetCBreak} sets the status of CTRL-Break checking under \dos.
  649. When \var{BreakValue} is \var{false}, then \dos only checks for the
  650. CTRL-Break key-press when I/O is performed. When it is set to \var{True},
  651. then a check is done at every system call.
  652. \Errors
  653. Under Linux, this call exists
  654. but is not implemented, i.e. it does nothing.
  655. \SeeAlso
  656. \seep{GetCBreak}
  657. \end{procedure}
  658. \begin{procedure}{SetDate}
  659. \Declaration
  660. Procedure SetDate (year,month,day: word);
  661. \Description
  662. \var{SetDate} sets the system's internal date. \var{Year} is a number
  663. between 1980 and 2099.
  664. \Errors
  665. On a \linux machine, this is not implemented (allthough a procedure
  666. exists, it just doesn't do anything. The setting of the date is a
  667. root-only privilege, and is hence not implemented.
  668. \SeeAlso
  669. \seep{Dos:GetDate},
  670. \seep{SetTime}
  671. \end{procedure}
  672. \begin{procedure}{SetFAttr}
  673. \Declaration
  674. Procedure SetFAttr (var F; Attr: word);
  675. \Description
  676. \var{SetFAttr} sets the file attributes of the file-variable \var{F}.
  677. \var{F} can be a untyped or typed file, or of type \var{Text}. \var{F} must
  678. have been assigned, but not opened. The attributes can be a sum of the
  679. following constants:
  680. \begin{itemize}
  681. \item \var{ReadOnly = 01h}
  682. \item \var{Hidden = 02h}
  683. \item \var{SysFile = 04h}
  684. \item \var{VolumeId = 08h}
  685. \item \var{Directory = 10h}
  686. \item \var{Archive = 20h}
  687. \item \var{AnyFile = 3fh}
  688. \end{itemize}
  689. \Errors
  690. Errors are reported in \var{DosError}.
  691. Under \linux the call exists, but is not implemented, i.e. it does nothing.
  692. \SeeAlso
  693. \seep{GetFAttr}
  694. \end{procedure}
  695. \begin{procedure}{SetFTime}
  696. \Declaration
  697. Procedure SetFTime (var F; Time: longint);
  698. \Description
  699. \var{SetFTime} sets the modification time of a file,
  700. this time is encoded and must be encoded with \var{PackTime}.
  701. \var{F} must be a file type, which has been assigned, and
  702. opened.
  703. \Errors
  704. Errors are reported in \var{DosError}
  705. \SeeAlso
  706. \seep{GetFTime}, \seep{PackTime},\seep{UnPackTime}
  707. \end{procedure}
  708. \begin{procedure}{SetIntVec}
  709. \Declaration
  710. Procedure SetIntVec (IntNo: byte; Vector: pointer);
  711. \Description
  712. \var{SetIntVec} sets interrupt vector \var{IntNo} to \var{Vector}.
  713. \var{Vector} should point to an interrupt procedure.
  714. \Errors
  715. Under non- \dos operating systems, this call does nothing.
  716. \SeeAlso
  717. \seep{GetIntVec}
  718. \end{procedure}
  719. \begin{procedure}{SetTime}
  720. \Declaration
  721. Procedure SetTime (hour,minute,second,sec100: word);
  722. \Description
  723. \var{SetTime} sets the system's internal clock. The \var{Hour} parameter is
  724. on a 24-hour time scale.
  725. \Errors
  726. this call exists, but is not implemented on \linux,
  727. as setting the time is a root-only privilege.
  728. \SeeAlso
  729. \seep{Dos:GetTime}, \seep{SetDate}
  730. \end{procedure}
  731. \begin{procedure}{SetVerify}
  732. \Declaration
  733. Procedure SetVerify (verify: boolean);
  734. \Description
  735. \var{SetVerify} sets the status of the verify flag under \dos. When
  736. \var{Verify} is \var{True}, then \dos checks data which are written to disk,
  737. by reading them after writing. If \var{Verify} is \var{False}, then data
  738. written to disk are not verified.
  739. \Errors
  740. Under \linux, Verify is always
  741. \var{True}.
  742. \SeeAlso
  743. \seep{SetVerify}
  744. \end{procedure}
  745. \begin{procedure}{SwapVectors}
  746. \Declaration
  747. Procedure SwapVectors ;
  748. \Description
  749. \var{SwapVectors} swaps the contents of the internal table of interrupt
  750. vectors with the current contents of the interrupt vectors.
  751. This is called typically in before and after an \var{Exec} call.
  752. \Errors
  753. Under \linux this call does nothing, as the interrupt vectors are
  754. managed by the kernel.
  755. \SeeAlso
  756. \seep{Exec}, \seep{SetIntVec}
  757. \end{procedure}
  758. \begin{procedure}{UnPackTime}
  759. \Declaration
  760. Procedure UnPackTime (p: longint; var T: datetime);
  761. \Description
  762. \var{UnPackTime} converts the file-modification time in \var{p}
  763. to a \var{DateTime} record. The file-modification time can be
  764. returned by \var{GetFTime}, \var{FindFirst} or \var{FindNext} calls.
  765. \Errors
  766. None.
  767. \SeeAlso
  768. \seep{GetFTime}, \seep{FindFirst}, \seep{FindNext}, \seep{PackTime}
  769. \end{procedure}
  770. For an example, see \seep{PackTime}.