Cstring: loadstring (uint NID)
Conclusion: The correct way to load string resource by ID is to call cstring: loadstring (hinstance, uint NID), specifying the DLL handler you want to search.
ProblemCstring: loadstring (uint NID) will first use
f = loadstring ("i=i+1") is basically equivalent to F = function () i=i+1 endBut the second piece of code is much faster than the first, because it is compiled only once when the corresponding program block is compiled, and the first piece of code
Dofile, which is treated as a primitive operation of the chunk that Lua runs the code. 1. Dofile is actually a helper function. The function that truly completes the function is LoadFile; 2. Unlike dofile, LoadFile compiles the code into an
Loadstring () function usage tips:The prototype declared by this function is int loadstring (hinstance, uint uid,Lptstr lpbuffer, int cchbuffermax );The third parameter is a pointer to the buffer that receives the load content,When we only need to
Copy Code code as follows:
Todo
Local errorinfo = LoadFile ("Test.lua"); --load code file
if (errorinfo = = nil) Then
Print ("Load file failed");
Else
Print ("Load file Success");
Local doinfo = Dofile ("Test.lua")--complie the
In fact, this is alsoProgramLoad the analysis instance of the resource.
Create a Win32 project.
The source code is as follows:
// testloadstr. cpp: defines the entry point of the application. // # Include "stdafx. H "# include" testloadstr. H "
Chinese version of programming in Lua -- 8. Compilation, execution, and errors Transferred from http://www.lifangjin.com/(liangfeng collection Li fangjin's personal blog)Although we use Lua as an interpreted language Code Pre-editing is translated
1. Compile:Lua providesDofileFunction, which is a built-in operation used to run LuaCodeBlock. But in fact, dofile is just an auxiliary function,LoadFileIs the true core function. Compared with dofile, LoadFile only loads the Lua code block from the
1. Compile:The Dofile function is provided in Lua, which is a built-in operation for running LUA blocks of code. But actually Dofile is just an auxiliary function, LoadFile is the real core function. Instead of Dofile,loadfile just loading the LUA
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.