lua-users home
lua-l archive

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


Hi everybody!

I'm a Lua newbie and I've been lurking on this list for some months.

<compliments>
Very nice language. I learnt about it because it is embedded in my favourite editor (SciTE). I must admit at first I was puzzled because I had never heard anything about it before and It looked quite different from the other languages I know (mainly Java, some C++, a bunch of different BASIC dialects and a bit of Python and, many years ago, some Pascal, C, Forth and Fortran). The real breakthrough in my programming experience using Lua has been functions as first class objects, (If only Java had them, instead of those crappy inner-classes!!! :-) . I also greatly appreciate the kindness and friendliness of this list, which is not so common among those "inhabited" by technically savy people or IT professionals!
</compliments>

Now to the point.
I need a way to make a Lua script know it's exact location, i.e. its absolute file system path (under Win XP is enough) using pure Lua and no C. My purpose is to build applications in pure Lua (or wxLua) that can automatically find their modules/components/data without any installation or shell script launcher (I'm playing with executables created using wxLuafreeze and plan also to use srlua to achieve a similar effect with plain Lua). I've searched the archive but found only some suggestions to parse arg[0], but this doesn't always work. In particular there are two use cases where it fails:

1. When invoking a script specifiying a relative path (that path is what arg[0] gets) like in the following invocation:
lua relative_path\myscript.lua

2. When invoking through a relative path an executables that is obtained freezing a wxLua script and this latter looks for another file using a path relative to the executable.
relative_path\myWxLuaFrozenApp.exe   ----> generates a file not found error

I'm missing something?
Thank you in advance. Any help or direction is appreciated.

Lorenzo Donati

P.S.: I apologize in advance for my possible future late replies, since I'm not always connected to the internet and, for various reasons, cannot connect frequently.