Next: 5.2 Converting Values between Up: 5 The Application Program Previous: 5 The Application Program

5.1 Executing Lua Code

A host program can execute Lua chunks written in a file or in a string, using the following functions:

int            lua_dofile               (char *filename);
int            lua_dostring             (char *string);
Both functions return an error code: 0, in case of success; non zero, in case of errors. The function lua_dofile , if called with argument NULL (0), executes the ``file'' stdin. Function lua_dofile is also able to execute pre-compiled chunks. It detects whether the file is text or not, and loads it accordingly (see program luac).


Next: 5.2 Converting Values between Up: 5 The Application Program Previous: 5 The Application Program