help-octave
[Top][All Lists]
Advanced

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

source-ing files vs. entering on cmd line?


From: John W. Eaton
Subject: source-ing files vs. entering on cmd line?
Date: Tue, 17 Nov 1998 14:39:49 -0600 (CST)

On 17-Nov-1998, Daniel Friedman <address@hidden> wrote:

| I am running Octave version 2.0.13.  Suppose I start Octave while in
| directory 'foo', and I have a file in ./bar/mstuff.m I wish to run, 
| to declare a bunch of special functions at the beginning of a particular
| session.  Without adding the 'bar' directory to LOADPATH, since I need
| the bar directory only once, is there a way to specify to octave where to
| look for mstuff.m just one time?  If I could enter "bar/mstuff" on the
| command line, that would be great, but this of course doesn't work.

The reason that you can't do that is that there is no way for Octave
to know that what you've typed is not a division expression.

| Do
| I have to change to the bar directory, run mstuff, and then change back
| where I was?
| 
| I tried source("bar/mstuff"), and this executes without error, but the
| functions defined in mstuff are not remembered by Octave for later use. 

As Mario Storti noted, you need to give the full name of the file:

  source ("bar/mstuff.m");

That you don't get an error when the file name is wrong looks like a
bug.  I think the following patch should fix the problem.

Thanks,

jwe


Tue Nov 17 14:35:56 1998  John W. Eaton  <address@hidden>

        * toplev.cc (Fsource): Check return value from parse_fcn_file.


*** src/toplev.cc~      Mon Nov  9 16:13:29 1998
--- src/toplev.cc       Tue Nov 17 14:33:38 1998
***************
*** 339,347 ****
        {
          file = oct_tilde_expand (file);
  
!         parse_fcn_file (file, true, true);
  
!         if (error_state)
            error ("source: error sourcing file `%s'", file.c_str ());
        }
        else
--- 339,347 ----
        {
          file = oct_tilde_expand (file);
  
!         int script_file_executed = parse_fcn_file (file, true, true);
  
!         if (error_state || ! script_file_executed)
            error ("source: error sourcing file `%s'", file.c_str ());
        }
        else



reply via email to

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