Sign in Join
Wiki copytemporary

Function/fr: what changed

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

Title: Function/fr

OldNewLine
1+## Overview
2+
3+Une **fonction** est une déclaration d'une [[Routine/fr|routine]] qui peut être invoquée
4+
5+- à partir d'une [[Unit/fr|unité]] qui la déclare
6+- depuis l'extérieur de l'unité si la fonction est publique,
7+- ou depuis un [[Program/fr|programme]]
8+
9+La routine retourne une valeur dans la cadre de sa définition. Une routine qui ne retourne pas de valeur dans le cadre de sa définition est une *[[Procedure/fr|procédure]]*.
10+
11+Une fonction qui fait partie d'une classe est appelée [[Property/fr|propriété]] et peut être affectée et retourner une valeur (si vous ne pouvez pas affecter de valeur, il s'agit d'une [[Method/fr|méthode]].
12+
13+## Paramètres de fonctions
14+
15+- Appel par valeur
16+- [[Variable parameter/fr|paramètre variable]] (Appel par référence)
17+- Paramètre out
18+- Paramètre Const
19+- [[Default parameter/fr|Default parameter]]
20+- Paramètre tableau ouvert
21+- Array of const
22+
23+## Exemples
24+
25+Exemple d'addition de deux [[Integer/fr|entiers]] :
26+
27+``` pascal
28+ function add(c1, c2 : integer) : integer;
29+ begin
30+ add := c1 + c2; //or use result := in Object Pascal/Delphi mode
31+ end;
32+
33+ var
34+ total: integer;
35+
36+ begin
37+ total := add(4, 5);
38+ writeln (total); // result is 9
39+ end.
40+```
41+
42+---
43+*From the Free Pascal wiki, page "Function/fr", as it stood on 2020-02-16 after a change by Trev, 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