|
From: Thomas S. <t.s...@fz...> - 2011-03-09 17:03:51
|
the best place to set such a variable would be the
'load_file()' routine in 'misc.c'.
two lines need to be added there:
--- misc.c.orig 2011-03-08 15:15:32.240304167 +0100
+++ misc.c 2011-03-09 18:00:13.300516216 +0100
@@ -215,6 +215,8 @@
lf_push(fp, name, NULL); /* save state for errors and recursion */
do_load_arg_substitution = can_do_args;
+ fill_gpval_string("GPVAL_LOAD_FILE", name);
+
if (fp == (FILE *) NULL) {
os_error(c_token, "Cannot open %s file '%s'",
can_do_args ? "call" : "load", name);
@@ -286,6 +288,8 @@
}
}
+ fill_gpval_string("GPVAL_LOAD_FILE", "");
+
/* pop state */
(void) lf_pop(); /* also closes file fp */
}
Robbie Morrison wrote:
>
>
> Hello all
>
> It would be rather useful if the current filename was
> available from within a gnuplot script.
>
> This suggestion was raised in 2008 and 2009
> respectively:
>
>
> http://groups.google.com/group/comp.graphics.apps.gnuplot/browse_thread/thread/2b34fa67a0365173/8f8c63c891f59aeb?lnk=gst&q=%22current+filename%22#8f8c63c891f59aeb
>
> http://groups.google.com/group/comp.graphics.apps.gnuplot/browse_thread/thread/781545ccfbaada56/ebffa12161a37fe3?lnk=gst&q=%22get+filename%22#ebffa12161a37fe3
>
> And, AFAIK, has not been resolved.
>
> One approach might be:
>
> assume the file 'myfile.gp' contains the lines:
>
> myfile = GPVAL_LOAD_FILE
> print "myfile = ", myfile
>
> then entering the command:
>
> load "myfile.gp"
>
> would display either of the following -- the first
> being a simple echo and the second being the canonical
> file path:
>
> myfile = myfile.gp
> myfile = /path/to/myfile.gp
>
> On termination, GPVAL_LOAD_FILE would be unset.
>
> Another approach (probably too late) would have been
> to have the 'call' command assign the filename to $0
> in line with most other shell positional variable
> conventions.
>
> If there is a work-around, that would be good to know.
>
> best wishes
> Robbie
> ---
> Robbie Morrison
> PhD student -- policy-oriented energy system simulation
> Technical University of Berlin (TU-Berlin), Germany
> University email (redirected) : mor...@ie...
> Webmail (preferred) : ro...@ac...
> [from Webmail client]
>
>
>
> ------------------------------------------------------------------------------
> What You Don't Know About Data Connectivity CAN Hurt You
> This paper provides an overview of data connectivity, details
> its effect on application quality, and explores various alternative
> solutions. http://p.sf.net/sfu/progress-d2d
> _______________________________________________
> gnuplot-info mailing list
> gnu...@li...
> https://lists.sourceforge.net/lists/listinfo/gnuplot-info
>
>
--
View this message in context: http://old.nabble.com/name-of-current-script-tp31095884p31108305.html
Sent from the Gnuplot - User mailing list archive at Nabble.com.
|