Difference between revisions of "Loadstring"

From GiderosMobile
m (Text replacement - "</source>" to "</syntaxhighlight>")
 
(One intermediate revision by the same user not shown)
Line 5: Line 5:
 
=== Description ===
 
=== Description ===
 
Gets the chunk from the given string.
 
Gets the chunk from the given string.
<source lang="lua">
+
<syntaxhighlight lang="lua">
 
(function) = loadstring(string,chunkname)
 
(function) = loadstring(string,chunkname)
</source>
+
</syntaxhighlight>
  
 
To load and run a given string, use the idiom:
 
To load and run a given string, use the idiom:

Latest revision as of 15:31, 13 July 2023

Available since: Gideros 2011.6
Class: (global)

Description

Gets the chunk from the given string.

(function) = loadstring(string,chunkname)

To load and run a given string, use the idiom:

assert(loadstring(s))()

Chunkname is used as the chunk name for error messages and debug information. When absent, chunkname defaults to the given string.

Parameters

string: (string) string to load and compile
chunkname: (string) is used as the chunk name for error messages and debug information optional

Return values

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