dos.tex 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850
  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 only}
  346. Under \linux, the \var{findfirst/findnext} calls have to be mimicked.
  347. An internal table of file descriptors is kept.
  348. When using different \var{searchrecs} at the same time,
  349. the system may run out of file descriptors for directories.
  350. The \linux implementation of the \dos unit therefore keeps a table of open
  351. directories, and when the table is full, closes one of the directories, and
  352. reopens another. This system is adequate but slow if you use a lot of
  353. \var{searchrecs}.
  354. So, to speed up the findfirst/findnext system, the \var{FindClose} call was
  355. implemented. When you don't need a \var{searchrec} any more, you can tell
  356. this to the \dos unit by issuing a \var{FindClose} call. The directory
  357. which is kept open for this \var{searchrec} is then closed, and the table slot
  358. freed.
  359. It is recommended to use the \linux call \var{Glob} when looking for files.
  360. \Errors
  361. None.
  362. \SeeAlso
  363. \seef{Glob}.
  364. \end{procedure}
  365. \begin{procedure}{FindFirst}
  366. \Declaration
  367. Procedure FindFirst (const Path: pathstr; Attr: word; var F: SearchRec);
  368. \Description
  369. \var{FindFirst} searches the file specified in \var{Path}, checks the
  370. atrributes specified in \var{Attr}. It returns a \var{SearchRec} record for
  371. further searching in \var{F}.
  372. \var{Path} can contain the wildcard characters \var{?} (matches any single
  373. character) and \var{*} (matches 0 ore more arbitrary characters). In this
  374. case \var{FindFirst} will return the first file which matches the specified
  375. criteria.
  376. If \var{DosError} is different from zero, no file(s) matching the criteria
  377. was(were) found.
  378. \Errors
  379. Errors are reported in DosError.
  380. \SeeAlso
  381. \seep{FindNext},
  382. \seep{FindClose}
  383. \end{procedure}
  384. \FPCexample{ex7}
  385. \begin{procedure}{FindNext}
  386. \Declaration
  387. Procedure FindNext (var f: searchRec);
  388. \Description
  389. \var{FindNext} takes as an argument a \var{SearchRec} from a previous
  390. \var{FindNext} call, or a \var{FindFirst} call, and tries to find another
  391. file which matches the criteria, specified in the \var{FindFirst} call.
  392. If \var{DosError} is different from zero, no more files matching the
  393. criteria were found.
  394. \Errors
  395. \var{DosError} is used to report errors.
  396. \SeeAlso
  397. \seep{FindFirst}, \seep{FindClose}
  398. \end{procedure}
  399. For an example, see \seep{FindFirst}.
  400. \begin{functionl}{FSearch}{Dos:FSearch}
  401. \Declaration
  402. Function FSearch (Path: pathstr; DirList: string) : pathstr;
  403. \Description
  404. \var{FSearch} searches the file \var{Path} in all directories listed in
  405. \var{DirList}. The full name of the found file is returned.
  406. \var{DirList} must be a list of directories, separated by semi-colons (or
  407. colons under \linux).
  408. When no file is found, an empty string is returned.
  409. \Errors
  410. None.
  411. \SeeAlso
  412. \seefl{FExpand}{Dos:FExpand}
  413. \end{functionl}
  414. \FPCexample{ex10}
  415. \begin{procedure}{FSplit}
  416. \Declaration
  417. Procedure FSplit (path: pathstr; \\ var dir: dirstr; var name: namestr;
  418. var ext: extstr);
  419. \Description
  420. \var{FSplit} splits a full file name into 3 parts : A \var{Path}, a
  421. \var{Name} and an extension (in \var{ext}.)
  422. Under \linux, the extension is taken to be all letters after the last dot
  423. (.).
  424. \Errors
  425. None.
  426. \SeeAlso
  427. \seefl{FSearch}{Dos:FSearch}
  428. \end{procedure}
  429. \FPCexample{ex12}
  430. \begin{procedure}{GetCBreak}
  431. \Declaration
  432. Procedure GetCBreak (var breakvalue: boolean);
  433. \Description
  434. \var{GetCBreak} gets the status of CTRL-Break checking under \dos.
  435. When \var{BreakValue} is \var{false}, then \dos only checks for the
  436. CTRL-Break key-press when I/O is performed. When it is set to \var{True},
  437. then a check is done at every system call.
  438. \Errors
  439. Under Linux, this exists but is
  440. not implemented, i.e. the call does nothing.
  441. \SeeAlso
  442. \seep{SetCBreak}
  443. \end{procedure}
  444. \begin{procedurel}{GetDate}{Dos:GetDate}
  445. \Declaration
  446. Procedure GetDate (var year, month, mday, wday: word);\Description
  447. \var{GetDate} returns the system's date. \var{Year} is a number in the range
  448. 1980..2099.\var{mday} is the day of the month,
  449. \var{wday} is the day of the week, starting with Sunday as day 0.
  450. \Errors
  451. None.
  452. \SeeAlso
  453. \seepl{GetTime}{Dos:GetTime},\seep{SetDate}
  454. \end{procedurel}
  455. \FPCexample{ex2}
  456. \begin{functionl}{GetEnv}{Dos:GetEnv}
  457. \Declaration
  458. Function GetEnv (EnvVar: String) : String;
  459. \Description
  460. \var{Getenv} returns the value of the environment variable \var{EnvVar}.
  461. Under \linux, case is important when looking for \var{EnvVar}.
  462. When there is no environment variable \var{EnvVar} defined, an empty
  463. string is returned.
  464. \Errors
  465. None.
  466. \SeeAlso
  467. \seef{EnvCount}, \seef{EnvStr}
  468. \end{functionl}
  469. \FPCexample{ex14}
  470. \begin{procedure}{GetFAttr}
  471. \Declaration
  472. Procedure GetFAttr (var F; var Attr: word);
  473. \Description
  474. \var{GetFAttr} returns the file attributes of the file-variable \var{f}.
  475. \var{F} can be a untyped or typed file, or of type \var{Text}. \var{f} must
  476. have been assigned, but not opened. The attributes can be examined with the
  477. following constants :
  478. \begin{itemize}
  479. \item \var{ReadOnly = 01h}
  480. \item \var{Hidden = 02h}
  481. \item \var{SysFile = 04h}
  482. \item \var{VolumeId = 08h}
  483. \item \var{Directory = 10h}
  484. \item \var{Archive = 20h}
  485. \end{itemize}
  486. Under \linux, supported attributes are:
  487. \begin{itemize}
  488. \item \var{Directory}
  489. \item \var{ReadOnly} if the current process doesn't have access to the file.
  490. \item \var{Hidden} for files whose name starts with a dot \var{('.')}.
  491. \end{itemize}
  492. \Errors
  493. Errors are reported in \var{DosError}
  494. \SeeAlso
  495. \seep{SetFAttr}
  496. \end{procedure}
  497. \FPCexample{ex8}
  498. \begin{procedure}{GetFTime}
  499. \Declaration
  500. Procedure GetFTime (var F; var Time: longint);
  501. \Description
  502. \var{GetFTime} returns the modification time of a file.
  503. This time is encoded and must be decoded with \var{UnPackTime}.
  504. \var{F} must be a file type, which has been assigned, and
  505. opened.
  506. \Errors
  507. Errors are reported in \var{DosError}
  508. \SeeAlso
  509. \seep{SetFTime}, \seep{PackTime},\seep{UnPackTime}
  510. \end{procedure}
  511. \FPCexample{ex9}
  512. \begin{procedure}{GetIntVec}
  513. \Declaration
  514. Procedure GetIntVec (IntNo: byte; var Vector: pointer);
  515. \Description
  516. \var{GetIntVec} returns the address of interrupt vector
  517. \var{IntNo}.
  518. \Errors
  519. Under non- \dos operating systems, this call does nothing.
  520. \SeeAlso
  521. \seep{SetIntVec}
  522. \end{procedure}
  523. \begin{function}{GetLongName}
  524. \Declaration
  525. function GetLongName(var p : String) : boolean;\Description
  526. This function is only implemented in the GO32V2 version of \fpc.
  527. \var{GetLongName} changes the filename \var{p} to a long filename
  528. if the \dos call to do this is successful. The resulting string
  529. is the long file name corresponding to the short filename \var{p}.
  530. The function returns \var{True} if the \dos call was successful,
  531. \var{False} otherwise.
  532. This function should only be necessary when using the DOS extender
  533. under Windows 95 and higher.
  534. \Errors
  535. If the \dos call was not succesfull, \var{False} is returned.
  536. \SeeAlso
  537. \seef{GetShortName}
  538. \end{function}
  539. \begin{function}{GetShortName}
  540. \Declaration
  541. function GetShortName(var p : String) : boolean;\Description
  542. This function is only implemented in the GO32V2 version of \fpc.
  543. \var{GetShortName} changes the filename \var{p} to a short filename
  544. if the \dos call to do this is successful. The resulting string
  545. is the short file name corresponding to the long filename \var{p}.
  546. The function returns \var{True} if the \dos call was successful,
  547. \var{False} otherwise.
  548. This function should only be necessary when using the DOS extender
  549. under Windows 95 and higher.
  550. \Errors
  551. If the \dos call was not successful, \var{False} is returned.
  552. \SeeAlso
  553. \seef{GetLongName}
  554. \end{function}
  555. \begin{procedurel}{GetTime}{Dos:GetTime}
  556. \Declaration
  557. Procedure GetTime (var hour, minute, second, sec100: word);
  558. \Description
  559. \var{GetTime} returns the system's time. \var{Hour} is a on a 24-hour time
  560. scale. \var{sec100} is in hundredth of a
  561. second.
  562. \Errors
  563. None.
  564. \SeeAlso
  565. \seepl{GetDate}{Dos:GetDate},
  566. \seep{SetTime}
  567. \end{procedurel}
  568. \FPCexample{ex3}
  569. \begin{procedure}{GetVerify}
  570. \Declaration
  571. Procedure GetVerify (var verify: boolean);
  572. \Description
  573. \var{GetVerify} returns the status of the verify flag under \dos. When
  574. \var{Verify} is \var{True}, then \dos checks data which are written to disk,
  575. by reading them after writing. If \var{Verify} is \var{False}, then data
  576. written to disk are not verified.
  577. \Errors
  578. Under \linux, Verify is always
  579. \var{True}.
  580. \SeeAlso
  581. \seep{SetVerify}
  582. \end{procedure}
  583. \begin{procedure}{Intr}
  584. \Declaration
  585. Procedure Intr (IntNo: byte; var Regs: registers);
  586. \Description
  587. \var{Intr} executes a software interrupt number \var{IntNo} (must be between
  588. 0 and 255), with processor registers set to \var{Regs}. After the interrupt call
  589. returned, the processor registers are saved in \var{Regs}.
  590. \Errors
  591. Under \linux this call does nothing, because interrupts are managed by the
  592. kernel. The only allowed interrupt is 80h, the Linux kernel entry interrupt.
  593. \SeeAlso
  594. \seep{MSDos}, see the \linux unit.
  595. \end{procedure}
  596. \begin{procedure}{Keep}
  597. \Declaration
  598. Procedure Keep (ExitCode: word);
  599. \Description
  600. \var{Keep} terminates the program, but stays in memory. This is used for TSR
  601. (Terminate Stay Resident) programs which catch some interrupt.
  602. \var{ExitCode} is the same parameter as the \var{Halt} function takes.
  603. \Errors
  604. Under non-\dos operating systems, this call does nothing.
  605. \SeeAlso
  606. \seem{Halt}{}
  607. \end{procedure}
  608. \begin{procedure}{MSDos}
  609. \Declaration
  610. Procedure MSDos (var regs: registers);
  611. \Description
  612. \var{MSDos} executes an MS-\dos call (int 21h). This is the same as doing a
  613. \var{Intr} call with an interrupt number of 21h.
  614. \Errors
  615. None.
  616. \SeeAlso
  617. \seep{Intr}
  618. \end{procedure}
  619. \begin{procedure}{PackTime}
  620. \Declaration
  621. Procedure PackTime (var T: datetime; var P: longint);
  622. \Description
  623. \var{UnPackTime} converts the date and time specified in \var{T}
  624. to a packed-time format which can be fed to \var{SetFTime}.
  625. \Errors
  626. None.
  627. \SeeAlso
  628. \seep{SetFTime}, \seep{FindFirst}, \seep{FindNext}, \seep{UnPackTime}
  629. \end{procedure}
  630. \FPCexample{ex4}
  631. \begin{procedure}{SetCBreak}
  632. \Declaration
  633. Procedure SetCBreak (breakvalue: boolean);
  634. \Description
  635. \var{SetCBreak} sets the status of CTRL-Break checking under \dos.
  636. When \var{BreakValue} is \var{false}, then \dos only checks for the
  637. CTRL-Break key-press when I/O is performed. When it is set to \var{True},
  638. then a check is done at every system call.
  639. \Errors
  640. Under Linux, this call exists
  641. but is not implemented, i.e. it does nothing.
  642. \SeeAlso
  643. \seep{GetCBreak}
  644. \end{procedure}
  645. \begin{procedure}{SetDate}
  646. \Declaration
  647. Procedure SetDate (year,month,day: word);
  648. \Description
  649. \var{SetDate} sets the system's internal date. \var{Year} is a number
  650. between 1980 and 2099.
  651. \Errors
  652. On a \linux machine, this is not implemented (allthough a procedure
  653. exists, it just doesn't do anything. The setting of the date is a
  654. root-only privilege, and is hence not implemented.
  655. \SeeAlso
  656. \seep{Dos:GetDate},
  657. \seep{SetTime}
  658. \end{procedure}
  659. \begin{procedure}{SetFAttr}
  660. \Declaration
  661. Procedure SetFAttr (var F; Attr: word);
  662. \Description
  663. \var{SetFAttr} sets the file attributes of the file-variable \var{F}.
  664. \var{F} can be a untyped or typed file, or of type \var{Text}. \var{F} must
  665. have been assigned, but not opened. The attributes can be a sum of the
  666. following constants:
  667. \begin{itemize}
  668. \item \var{ReadOnly = 01h}
  669. \item \var{Hidden = 02h}
  670. \item \var{SysFile = 04h}
  671. \item \var{VolumeId = 08h}
  672. \item \var{Directory = 10h}
  673. \item \var{Archive = 20h}
  674. \item \var{AnyFile = 3fh}
  675. \end{itemize}
  676. \Errors
  677. Errors are reported in \var{DosError}.
  678. Under \linux the call exists, but is not implemented, i.e. it does nothing.
  679. \SeeAlso
  680. \seep{GetFAttr}
  681. \end{procedure}
  682. \begin{procedure}{SetFTime}
  683. \Declaration
  684. Procedure SetFTime (var F; Time: longint);
  685. \Description
  686. \var{SetFTime} sets the modification time of a file,
  687. this time is encoded and must be encoded with \var{PackTime}.
  688. \var{F} must be a file type, which has been assigned, and
  689. opened.
  690. \Errors
  691. Errors are reported in \var{DosError}
  692. \SeeAlso
  693. \seep{GetFTime}, \seep{PackTime},\seep{UnPackTime}
  694. \end{procedure}
  695. \begin{procedure}{SetIntVec}
  696. \Declaration
  697. Procedure SetIntVec (IntNo: byte; Vector: pointer);
  698. \Description
  699. \var{SetIntVec} sets interrupt vector \var{IntNo} to \var{Vector}.
  700. \var{Vector} should point to an interrupt procedure.
  701. \Errors
  702. Under non- \dos operating systems, this call does nothing.
  703. \SeeAlso
  704. \seep{GetIntVec}
  705. \end{procedure}
  706. \begin{procedure}{SetTime}
  707. \Declaration
  708. Procedure SetTime (hour,minute,second,sec100: word);
  709. \Description
  710. \var{SetTime} sets the system's internal clock. The \var{Hour} parameter is
  711. on a 24-hour time scale.
  712. \Errors
  713. this call exists, but is not implemented on \linux,
  714. as setting the time is a root-only privilege.
  715. \SeeAlso
  716. \seep{Dos:GetTime}, \seep{SetDate}
  717. \end{procedure}
  718. \begin{procedure}{SetVerify}
  719. \Declaration
  720. Procedure SetVerify (verify: boolean);
  721. \Description
  722. \var{SetVerify} sets the status of the verify flag under \dos. When
  723. \var{Verify} is \var{True}, then \dos checks data which are written to disk,
  724. by reading them after writing. If \var{Verify} is \var{False}, then data
  725. written to disk are not verified.
  726. \Errors
  727. Under \linux, Verify is always
  728. \var{True}.
  729. \SeeAlso
  730. \seep{SetVerify}
  731. \end{procedure}
  732. \begin{procedure}{SwapVectors}
  733. \Declaration
  734. Procedure SwapVectors ;
  735. \Description
  736. \var{SwapVectors} swaps the contents of the internal table of interrupt
  737. vectors with the current contents of the interrupt vectors.
  738. This is called typically in before and after an \var{Exec} call.
  739. \Errors
  740. Under \linux this call does nothing, as the interrupt vectors are
  741. managed by the kernel.
  742. \SeeAlso
  743. \seep{Exec}, \seep{SetIntVec}
  744. \end{procedure}
  745. \begin{procedure}{UnPackTime}
  746. \Declaration
  747. Procedure UnPackTime (p: longint; var T: datetime);
  748. \Description
  749. \var{UnPackTime} converts the file-modification time in \var{p}
  750. to a \var{DateTime} record. The file-modification time can be
  751. returned by \var{GetFTime}, \var{FindFirst} or \var{FindNext} calls.
  752. \Errors
  753. None.
  754. \SeeAlso
  755. \seep{GetFTime}, \seep{FindFirst}, \seep{FindNext}, \seep{PackTime}
  756. \end{procedure}
  757. For an example, see \seep{PackTime}.