lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


G'Day,

	Thanks for the prompt reply!  I am glad to see it is simple enough to
do to!

> > ...Is it
> > possible to evaluate a file before attempting to run it (such as the -c
> > argument with perl)?  In other words, can I check that it is
> > syntactically correct in any way other than actual execution of the
> > code.
> 
> Try:
> 
>     local chunk, err = loadfile("myfile.lua")
> 
>     if chunk then
>        print("All's well")
>     else
>        print("error in file: " .. err)
>     end

	I assume chunk contains the contents of my .lua file now: do I use this
in some way, or should I change it to `if chunk then dofile()'?  I think
I may make a simple function for this, so I can call it often: I can
definitely see myself using something like this a lot!

	Thanks again,

	Matthew