---
title: "Loading Program Files"
canonical: "https://docs.magma-maths.org/v2.30-1/MagmaLanguage/InputOutput/load.html"
source: "https://docs.magma-maths.org/v2.30-1/MagmaLanguage/InputOutput/load.md"
part: "The Magma Language"
chapter: "Input and Output"
breadcrumbs:
  - {"title": "Magma Handbook", "source": "https://docs.magma-maths.org/v2.30-1/index.md"}
  - {"title": "The Magma Language", "source": "https://docs.magma-maths.org/v2.30-1/MagmaLanguage/index-magma-language.md"}
  - {"title": "Input and Output", "source": "https://docs.magma-maths.org/v2.30-1/MagmaLanguage/InputOutput/index-input-output.md"}
prev: {"title": "Asynchronous I/O", "source": "https://docs.magma-maths.org/v2.30-1/MagmaLanguage/InputOutput/asyncio.md"}
next: {"title": "Saving and Restoring Workspaces", "source": "https://docs.magma-maths.org/v2.30-1/MagmaLanguage/InputOutput/workspace.md"}
intrinsics:
  - {"name": "Load", "signature": "Load(F): MonStgElt"}
  - {"name": "Load", "signature": "Load(Q): [MonStgElt]"}
  - {"name": "load", "signature": "load \"filename\";"}
  - {"name": "iload", "signature": "iload \"filename\";"}
---

# Loading Program Files

<a id="procedure-load-monstgelt"></a>
## `Load(F): MonStgElt`

(Procedure.) Specify that the file with the name given by the string $F$ (which may be any expression which evaluates to a string) is to be loaded immediately after this procedure call. Like the `load` directive below, the file $F$ will then be read in, and the text will be treated as Magma input. Tilde expansion of file names is allowed. This procedure call may only be used in a simple statement at the top level.

<a id="procedure-load-monstgelt-2"></a>
## `Load(Q): [MonStgElt]`

(Procedure.) Specify that the files with the names given by the strings in sequence $Q$ are to be loaded in order immediately after this procedure call. As above, the files will be read in, and the text will be treated as Magma input. Tilde expansion of file names is allowed. The empty sequence is allowed for $Q$, in which case nothing is loaded. This procedure call may only be used in a simple statement at the top level.

<a id="literal-literal-load-load-filename"></a>
## `load "filename";`

(Special top level directive.) Input the file with the name specified by the string. The file will be read in, and the text will be treated as Magma input. Tilde expansion of file names is allowed.

A file name that is a valid identifier may also be given without quotes, as in `load myfile;`. A relative name, quoted or not, is looked for in the current directory, then in the directories listed in `MAGMA_PATH`, then in each `MAGMA_LIBRARIES` subdirectory of `MAGMA_LIBRARY_ROOT`. Unless `MAGMA_LIBRARY_ROOT` is already set, the `magma` start-up script sets it to the `libs` directory of the installation, described in `libs/README`. See `SetPath` and `SetLibraries` in [Set and Get](https://docs.magma-maths.org/v2.30-1/MagmaLanguage/EnvironmentAndOptions/Set-Get.md).

<a id="literal-literal-iload-iload-filename"></a>
## `iload "filename";`

(Interactive load: special top level directive.) Input the file with the name specified by the string. The file will be read in, and the text will be treated as Magma input. Tilde expansion of file names is allowed. In contrast to `load`, the user has the chance to interact as each line is read in:

As the line is read in, it is displayed and the system waits for user response. At this point, the user can skip the line (by moving “down”), edit the line (using the normal editing keys) or execute it (by pressing “enter”). If the line is edited, the new line is executed and the original line is presented again.
