docs: add syntax hightlighting to code examples

This commit is contained in:
slederer 2024-10-30 00:37:56 +01:00
parent 796d8f8e5f
commit e71b928ae5

View file

@ -6,7 +6,7 @@ Passing strings of different maximum sizes as parameters is possible and safe be
When allocating a pointer to a string with **new**, you can specify a maximum size that is being allocated, so you can allocate less memory than the string type specifies. The string header fields will reflect the allocated size.
Example:
```
```pascal
type strPtrType: ^string[1024];
var p: ^strPtrType;
@ -23,7 +23,7 @@ When indexing a string, the result is a **char** type with bits 31 to 8 set to z
The for-in-loop is supported, which allows iterating over a string or a linear array of scalar variables. It is more efficient than using a for loop for indexing a string or an array, because no bounds checks are needed on each iteration.
String Example:
```
```pascal
var s:string;
c:char;
@ -38,7 +38,7 @@ var s:string;
```
Array Example:
```
```pascal
var a:array [1..3] of integer;
i:integer;
@ -57,7 +57,7 @@ var a:array [1..3] of integer;
The maximum number of elements in a set is 32. This makes a SET OF CHAR impossible.
When using a SET OF CHAR in other Pascal dialects, it is most often used with a set literal like this:
```
```pascal
var c:char;
read(c);
@ -73,7 +73,7 @@ Note that the array _in_ operator will be more inefficient for larger ranges (i.
A set literal can only appear on the right side of an assignment to a set variable, or when passing an argument of a set type to a procedure/function.
Example:
```
```pascal
program settest;
type weekday = (Mon,Tue,Wed,Thu,Fri,Sat,Sun);
days = set of weekday;
@ -140,7 +140,7 @@ There are five modes for opening files which (hopefully) cover all common use ca
- _ModeAppend_: file is opened for writing, data is always written to the end of the file
Example:
```
```pascal
var f:file;
c:char;
a,b:integer;
@ -160,7 +160,7 @@ That means you can either write programs without checking for I/O errors, while
The function _ErrorStr_ from the standard library takes an error code as an argument and returns the corresponding textual description as a string.
Example:
```
```pascal
procedure tryToReadFile;
var f:file;
begin
@ -204,7 +204,7 @@ This means, for example:
- for _string_, _read_ returns after a newline (CR) has been entered, which will not be part of the string
So to wait for a single keystroke, you can use:
```
```pascal
var c:char;
...
@ -232,7 +232,7 @@ The _Include_ directive reads another source file at compile time. Includes can
a string must be specified that indicates the file name.
Example:
```
```pascal
program includetest;
{$I 'morestuff.pas'}
@ -253,7 +253,7 @@ in kilobytes. The default value is 256.
The directive must appear before the _program_ keyword to have an effect.
Example:
```
```pascal
{$H 800}
program bigHeap;
@ -267,7 +267,7 @@ in kilobytes. The default value is 16.
The directive must appear before the _program_ keyword to have an effect.
Example:
```
```pascal
{$S 128}
program deepRecursion;
@ -281,7 +281,7 @@ This directive is a hack to make the Tridora compiler ignore directives meant fo
This directive uses the character _!_. After this directive, the rest of the line is not parsed. The closing comment is still required.
Example:
```
```pascal
{$!}uses math,crt;
```
In this example, the line is ignored by the Tridora compiler but FPC will parse it.