HexLibraryHexLibrary
</> HexCodeSign inSign up
PythonJavaScriptTypeScriptCC++JavaPHPGoRustRubyBashSQLLuaPerlCOBOLPascalDelphiFortranDartSwiftC#JuliaGroovyRElixirHaskellKotlinScalaClassic ASPClipperMS-DOS
LESSONS
Introduction to DelphiVariablesData Types & ConversionOperatorsStringsConditions (if)Loops (for / while)Functions
REFERENCE
📖 Overview
🖥️ Output
📦 Variables
🔄 Data Types & Conversion
✍️ String
🔁 Condition & Loop
🧩 Function & Procedure
functionprocedure
Delphi›REFERENCE›Function & Procedure›function

function

Subroutine that returns a value.

Syntax

function name(x: Type): Type; begin name := ...; end;

Description

The return value is assigned to the function name (or Result). It is defined before begin. div is integer division, mod is remainder.

Example

Loading editor…

Expected output

25

When to use?

Preventing code repetition.

Common mistakes

  • ⚠️ The return value is assigned to the function name: square := x*x; (no return keyword).

Related commands

procedure
procedure →
HexLibraryHexLibrary

Learn programming more clearly. Every command is explained line by line with colors, reinforced with runnable exercises, test your code instantly — all in one place, free.

Learn

  • Home
  • Languages & Lessons
  • HexCode

Company

  • About
  • Contact

Legal

  • Privacy Policy
  • Terms of Use

Other Projects

  • HexToolz
  • Free Service Manuals
© 2026 HexLibrary · The clearest way to learn code