Difference between revisions of "Loadstring"

From GiderosMobile
m (Text replacement - "</source>" to "</syntaxhighlight>")
 
(5 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>Class</translate>:''' [[Special:MyLanguage/(global)|(global)]]<br/>
+
'''Class:''' [[(global)]]<br/>
=== <translate>Description</translate> ===
 
<translate>Gets the chunk from the given string.
 
To load and run a given string, use the idiom
 
  
    `assert(loadstring(s))()`
+
=== Description ===
 +
Gets the chunk from the given string.
 +
<syntaxhighlight lang="lua">
 +
(function) = loadstring(string,chunkname)
 +
</syntaxhighlight>
 +
 
 +
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.</translate>
+
Chunkname is used as the chunk name for error messages and debug information. When absent, chunkname defaults to the given string.
<source lang="lua">
+
 
(function) = loadstring(string,chunkname)
+
=== Parameters ===
</source>
+
'''string''': (string) string to load and compile<br/>
=== <translate>Parameters</translate> ===
+
'''chunkname''': (string) is used as the chunk name for error messages and debug information '''optional'''<br/>
'''string''': (string) <translate>string to load and compile</translate> <br/>
+
 
'''chunkname''': (string) <translate>is used as the chunk name for error messages and debug information.</translate> '''optional'''<br/>
+
=== Return values ===
=== <translate>Return values</translate> ===
+
'''Returns''' (function) compiled chunk as a function, otherwise returns nil<br/>
'''<translate>Returns</translate>''' (function) <translate>compiled chunk as a function; otherwise, returns nil</translate><br/>
+
 
 +
{{(global)}}

Latest revision as of 14: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