On Fri, May 4, 2012 17:44, dhkblas...@zeelandnet.nl wrote: > On 4 mei '12, michael.vancann...@wisa.be wrote: >> On Fri, 4 May > 2012, michael.vancann...@wisa.be [3]wrote: >> >>> On Fri, 4 May 2012, > dhkblas...@zeelandnet.nl [1]wrote: >>> >>>> I'm creating a script to be > executed by instantfpc when I noticed that paramstr(0) does not reflect > the location of the script but the location of the cached executable. Is > there a way to alter this location programatically to the script > location? Is there an alternative way? >>> The solution can be found on > http://www.freepascal.org/docs-html/prog/progsu38.html [2] Const > ScriptName = {$INCLUDE FILE}; >> >> Come to think of it, probably not > 100% what you want. >> It will contain the name of the temporary script > file. > > Indeed, > it's not. ScriptName will contain "configure.ppx.pas". What I want it > that ParamStr(0) will contain the full filename to the script file > instead of the compiled version. This should be the default behaviour > imho b ecause it's an "executable" script and not a source file anymore.
There are two parts for a possible solution. The first part should be feasible without major issues (with it still requires someone to do it, e.g. provide a patch) - InstantFPC could add the name of the original script (including full path) as a predefined constant into the Pascal source while extracting it from the original script file. If you insist on receiving this path as ParamStr (0) result, it gets a bit more complicated. Basically, the only at least partly reasonable solution coming to my mind is having InstantFPC added a new function ParamStr locally to the script during extraction of the "temporary script" (aka Pascal source file). This overridden ParamStr function would then call System.ParamStr for all values except for ParamStr (0). This isn't much more difficult than just adding the constant described above, but it wouldn't solve cases like explicit reference to System.ParamStr (0). Also, any other RTL/FCL/... functions using ParamStr (0) (which may be in turn used from your script) would still refer to the standard System.ParamStr (0). You may not like it, but at least it wouldn't break existing standard functionality like enhanced backtraces when compiled with -gl (btw, adding the local ParamStr on a single source line would even allow these backtraces to refer to the correct line numbers from the original script file ;-) ). Tomas _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal