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! [import]uid: 99244 topic_id: 18559 reply_id: 318559[/import]

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

-David [import]uid: 96411 topic_id: 18559 reply_id: 71295[/import]

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. [import]uid: 58849 topic_id: 18559 reply_id: 72261[/import]