[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: detect if the current file is the main file ?
- From: Niklas Frykholm <niklas@...>
- Date: Mon, 15 May 2006 09:05:43 +0200
Hi,
I know in python it is possible to detect if a file is used as a module
or used as the main programm. And if it is run as the main programm run
a main function.
Is it possible to do the same with lua ? I tried with some
debug functions without success.
I've been using this (suppose the file is called "test.lua"):
if arg[0]:find("test%.lua$") then
main()
end
It's not foolproof. The end user could have renamed the file "test.lua".
Or he could be running some other program that ends in "test.lua".
// Niklas