From octave-maintainers-request at bevo dot che dot wisc dot edu Tue Mar 25 08:42:04 2003 Subject: Re: Problem with load From: Andy Adler To: "John W. Eaton" cc: octave-maintainers at bevo dot che dot wisc dot edu Date: Tue, 25 Mar 2003 09:41:44 -0500 (EST) On Mon, 24 Mar 2003, John W. Eaton wrote: > On 22-Feb-2003, Andy Adler wrote: > > | On Sat, 22 Feb 2003, John W. Eaton wrote: > | > It seems to me that if you want to load a file, you > | > should probably be asking for exactly the file you want. But maybe > | > other people feel differently? If so, what are the reasons (other > | > than compatibility) that this feature is a good idea? > | > | Here is my reason: > | > | if exist('processed_data.mat') > | load processed_data.mat > | else > | processed_data = recalculate_from_raw_data(); > | end > | > | Right now exist() doesn't tell me where it is, so > | there is no way I can issue the load command. > | > | The fixes are: 1) have a way to know where it is, or > | 2) have load pick it up automatically. > | Matlab compatibility pushes for #1. > | > | On the other hand, this could be a switch to load. > > Couldn't you use file_in_loadpath to find the file? It returns an > empty matrix if it doesn't find the file you are looking for. Also, > you can use the optional argument "all" to find all the files with the > given name. In that case, you could also warn about possible problems > due to duplicates. That's a good idea. I didn't think of file_in_loadpath. Could we at least change the help documentation to give an example with file_in_loadpath to get Matlab compatible behaviour. For example: Unlike the equivalent Matlab command, octave will not search the LOADPATH to find the file. If such behaviour is desired, then the following approach may be used: filepath= file_in_loadpath( file ); if ~isempty( filepath ); load(filepath); else error(["Can't file ', file, ' in LOADPATH']) end Andy