help-octave
[Top][All Lists]
Advanced

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

Re: detecting .m file name


From: John W. Eaton
Subject: Re: detecting .m file name
Date: Tue, 23 Jun 1998 15:58:12 -0500 (CDT)

On 23-Jun-1998, Wonkoo Kim <address@hidden> wrote:

| Suppose "foo.m" has a line:
| 
|   eval(sprintf("gset output \"%s.ps\"", this_script_name));
| 
| and I want the above line does
| 
|   gset output "foo.ps"  (or, gset output "foo.m.ps")
| 
| when I run it from Octave.

Please try the following patch.

Thanks,

jwe


Tue Jun 23 15:09:54 1998  John W. Eaton  <address@hidden>

        * variables.cc (clear_current_script_file_name): New function.
        (parse_fcn_file): Bind current_script_file_name while script is
        executing.  Use unwind_protect to clear it once the script is
        finished.


*** src/variables.cc~   Wed May 13 22:49:15 1998
--- src/variables.cc    Tue Jun 23 15:49:46 1998
***************
*** 636,641 ****
--- 636,647 ----
      fclose ((FILE *) f);
  }
  
+ static void
+ clear_current_script_file_name (void *)
+ {
+   bind_builtin_variable ("current_script_file_name", octave_value ());
+ }
+ 
  int
  parse_fcn_file (const string& ff, bool exec_script, bool force_script)
  {
***************
*** 732,737 ****
--- 738,747 ----
  
          Vsaving_history = 0;
          reading_script_file = 1;
+ 
+         add_unwind_protect (clear_current_script_file_name, 0);
+ 
+         bind_builtin_variable ("current_script_file_name", ff);
  
          parse_and_execute (ffile, 1);
  



reply via email to

[Prev in Thread] Current Thread [Next in Thread]