How to "include" a file not "require"?

I don't think this is the same as as "require". I want to place any text file in the middle of my LUA file, and run it like it was one file. I did Google searches but maybe I'm not using the correct terms because I could not find anything. The closest thing I found was "doFile" but it says Corona doesn't support it.

Thanks!

Assuming you are talking about a code file, there is no "include" directive like the C language in the Cornoa environment.

-David

If you really, really need this, you can achieve C #include like this:
1) make a "source directory"
2) make an "export directory"
3) download some preprocessor tool or develop your own that supports #include directive
4) write a script which calls PP on .lua files in the source directory and writes output files to export directory
5) execute said script before running Corona on export directory, and needs to be rerun whenever source dir files are edited

IMO it's too much work. Try to use what's supported in Corona instead: The Lua module system.

Dofile is not the same as a C# include, it dynamically executes code in a another file (but due to Lua scoping the effect can be similar). I believe it was disabled for security reasons - it for instance would allow an app to download Lua code from somewhere else and arbitrarily execute it.

views:1648 update:2011/12/30 9:10:41
corona forums © 2003-2011