Sign in Join
Wiki copytemporary

sysutils: what changed

Revision 0 to 1. Removed lines have a minus sign; added lines have a plus sign.

Title: sysutils

OldNewLine
1+The [[Unit|unit]] **`sysUtils`** shipped with the [[FPC|FPC’s]] default [[RTL|run-time library]] provides many system utilities. It attempts to be as compatible to [[Delphi|Delphi’s]] `sysUtils` unit as possible. However, the FPC version is available on [[Platform list|all platforms that the FPC supports]]. It does not contain any Windows-related routines or other highly platform-specific functionality.
2+
3+## Notable functionality
4+
5+- [[Format function|format]]
6+- [[Executing External Programs|executeProcess for executing external programs]]
7+- several routines ensuring productive use of [[TDateTime|tDateTime]]
8+- [type helpers for all basic data types](https://www.freepascal.org/docs-html/rtl/sysutils/typehelpers.html)
9+- [[FreeAndNil|freeAndNil]]
10+- routines to access [[Command line parameters and environment variables|environment variables]]
11+
12+## Caveats
13+
14+[If the `sysUtils` unit is included](https://www.freepascal.org/docs-html/rtl/system/runtimeerrors.html), all [[runtime error|run-time errors]] become [[Exceptions|exceptions]], which virtually forces you to use a [[Compiler Mode|compiler mode]] (or [[modeswitch|mode switch]]) that allows exception treatment. To catch an exception by its name you will need to include `sysUtils`, even though the module itself does not use any of the included system utilities.
15+
16+Changing run-time errors to exceptions has a *global* effect. The following program will terminate with an uncaught *exception*, even though it does not list `sysUtils` in its `uses`-clause: The `sysUtils` unit is *implicitly* included via the [`strUtils` unit](https://www.freepascal.org/docs-html/rtl/strutils/index.html):
17+
18+``` pascal
19+program implicitSysUtilsCaveat(input, output, stdErr);
20+uses
21+ strUtils;
22+var
23+ x: file of char;
24+ c: char;
25+begin
26+ // deliberately cause an error for demonstration purposes
27+ read(x, c);
28+end.
29+```
30+
31+Also, if [[Size Matters|size matters]], using `sysUtils` is by design not the smartest choice.
32+
33+## See also
34+
35+- [`sysUtils` reference](https://www.freepascal.org/docs-html/rtl/sysutils/index.html)
36+- [Delphi’s `sysUtils` unit](http://docwiki.embarcadero.com/Libraries/Sydney/en/System.SysUtils)
37+- [[libc library]]
38+- [[System unit|system unit]]
39+
40+---
41+*From the Free Pascal wiki, page "sysutils", as it stood on 2021-02-06 after a change by Kai Burghardt, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).*

Back to history