Difference between revisions of "Loadfile"

From GiderosMobile
 
(6 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
__NOTOC__
 
__NOTOC__
'''<translate>Available since</translate>:''' Gideros 2011.6<br/>
+
'''Available since:''' Gideros 2011.6<br/>
=== <translate>Description</translate> ===
+
'''Class:''' [[(global)]]<br/>
<translate>Loads a chunk from the file without execution.
 
  
If there are no errors, returns the compiled chunk as a function; otherwise, returns nil plus the error message. The environment of the returned function is the global environment.</translate>
+
=== Description ===
<source lang="lua">
+
Loads a chunk from the file without execution.
 +
<syntaxhighlight lang="lua">
 
(function) = loadfile(filename)
 
(function) = loadfile(filename)
</source>
+
</syntaxhighlight>
=== <translate>Parameters</translate> ===
+
 
'''filename''': (string) <translate>name of the file to load</translate> <br/>
+
If there are no errors, returns the compiled chunk as a function, otherwise returns nil plus the error message. The environment of the returned function is the global environment.
=== <translate>Return values</translate> ===
+
 
'''<translate>Returns</translate>''' (function) <translate>compiled chunk as a function; otherwise, returns nil</translate><br/>
+
=== Parameters ===
 +
'''filename''': (string) name of the file to load<br/>
 +
 
 +
=== Return values ===
 +
'''Returns''' (function) compiled chunk as a function, otherwise returns nil<br/>
 +
 
 +
=== Example ===
 +
'''You may need to exclude ''myfile.lua'' from execution'''
 +
<syntaxhighlight lang="lua">
 +
local level = loadfile("myfile.lua")()
 +
</syntaxhighlight>
 +
 
 +
{{(global)}}

Latest revision as of 05:12, 2 December 2023

Available since: Gideros 2011.6
Class: (global)

Description

Loads a chunk from the file without execution.

(function) = loadfile(filename)

If there are no errors, returns the compiled chunk as a function, otherwise returns nil plus the error message. The environment of the returned function is the global environment.

Parameters

filename: (string) name of the file to load

Return values

Returns (function) compiled chunk as a function, otherwise returns nil

Example

You may need to exclude myfile.lua from execution

local level = loadfile("myfile.lua")()