Loadstring: Difference between revisions
From GiderosMobile
No edit summary |
No edit summary |
||
| Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
'''Available since:''' Gideros 2011.6<br/> | |||
''' | '''Class:''' [[(global)]]<br/> | ||
''' | |||
=== | === Description === | ||
Gets the chunk from the given string. | |||
<source lang="lua"> | <source lang="lua"> | ||
(function) = loadstring(string,chunkname) | (function) = loadstring(string,chunkname) | ||
</source> | </source> | ||
=== | To load and run a given string, use the idiom: | ||
'''string''': (string) | |||
'''chunkname''': (string) | ''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<br/> | |||
'''chunkname''': (string) is used as the chunk name for error messages and debug information '''optional'''<br/> | |||
=== | === Return values === | ||
''' | '''Returns''' (function) compiled chunk as a function, otherwise returns nil<br/> | ||
{{(global)}} | {{(global)}} | ||
Revision as of 21:06, 13 May 2022
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