bugGNU Octave - Bugs: bug #37467, Errors in 'm' files

 
 

bug #37467: Errors in 'm' files

Submitted by:  None
Submitted on:  Sat 29 Sep 2012 03:18:26 PM UTC  
 
Category: NoneSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Matlab Compatibility
Status: InvalidAssigned to: None
Originator Name: Charles BondOriginator Email: -unavailable-
Open/Closed: ClosedRelease: 3.6.1
Operating System: Microsoft Windows

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

(Jump to the original submission Jump to the original submission)

Mon 01 Oct 2012 06:22:09 PM UTC, comment #15:

Matlab does:

First, it does a test:

>> run 'foo.m'

??? Undefined variable "foo" or class "foo.m".

Error in ==> run at 74
evalin('caller',[script ';']);
=================
This appears to test for .m as the suffix.
If foo.m is copied to foo, Matlab runs it
if it is a "script" (no .m) with or without
the first line: function [ ret ] = foo().
It appears to just ignore the first line.

I would say that the Matlab behaviour is about as
confusing as the current Octave behaviour.

It might be better if Octave threw an error
if foo.m is a function, but ran it if it is a script.
This would decided if it contains a function
declaration.
The fact that Matlab will not run a "script" who's
name ends with suffix .m seems, to me, not very
reasonable. But, I would not much object to this
bit of "Matlab compatibility."

Michael Godfrey <godfrey>
Project Member
Mon 01 Oct 2012 05:49:15 PM UTC, comment #14:

The "run" command is intended to run scripts that are not located somewhere on the path.

Maybe "run" should warn or throw an error when it is asked to run a function? What does Matlab do?

John W. Eaton <jwe>
Project Administrator
Mon 01 Oct 2012 05:40:56 PM UTC, comment #13:

Maybe 'run' should be 'execute'. But,
why does no output appear for run foo.m?

Isn't this a bug?

Michael Godfrey <godfrey>
Project Member
Mon 01 Oct 2012 05:35:11 PM UTC, comment #12:

Yeah, I would avoid mentioning "run" in the warning.

John W. Eaton <jwe>
Project Administrator
Mon 01 Oct 2012 05:24:44 PM UTC, comment #11:

function [ ret ] = foo()
printf ("Hello!\n");
endfunction

Now, issuing
foo
differs from
run foo.m
in the sense that the latter doesn't emit any output:

(Octave-3.6.2_MSVC)
...so there's the next pitfall looming for unwary users / n00bs.

Philip Nienhuis <philipnienhuis>
Project Member
Mon 01 Oct 2012 12:53:24 PM UTC, comment #10:

This is a good idea. Would a warning (or maybe error)
Would something like:

`foo.m' appears to be a script
file or it is not in `load' format. Script files are
run by `foo.m.' See 'help load' for use of the load command.

be clearer?

Michael Godfrey <godfrey>
Project Member
Mon 01 Oct 2012 12:30:05 PM UTC, comment #9:

Newbies keep trying to execute m-files with the load command. Any suggestion on the wording for a warning against this? I'm thinking something like "warning: attempting to load data from executable script `foo.m'. Consider `foo' or `run foo.m' instead."

Jordi GutiƩrrez Hermoso <jordigh>
Project Administrator
Sun 30 Sep 2012 07:22:37 PM UTC, comment #8:

Sorry to all. I apparently have a major misunderstanding about Octave. Please ignore my posts and thanks for the help. I'll read everything I can find in the manual before I post again.

Anonymous
Sun 30 Sep 2012 04:20:51 PM UTC, comment #7:

You said:

"3. The contents of the files which fail can be entered from the
keyboard and run OK. "

But, this is not relevant to the use of the load command.
The load command, as the documentation explains, is for
loading variables into Octave.

Michael Godfrey <godfrey>
Project Member
Sun 30 Sep 2012 04:10:38 PM UTC, comment #6:

It would make it much easier to understand your
problem if you could provide the name of a ".m" file which
fails to load.

Michael Godfrey <godfrey>
Project Member
Sun 30 Sep 2012 04:05:59 PM UTC, comment #5:

Please reread my original post.
1. I am able to load and run some 'm' files without problem.
2. Some files fail to load and report matrix dimension errors.
3. The contents of the files which fail can be entered from the
keyboard and run OK.
4. All files under discussion are part of the distribution.

My question was not "how to execute an *.m file, but whether
anyone has seen a problem with files from the distribution failing
to run, when the same file data entered from the keyboard will work?

Anonymous
Sat 29 Sep 2012 10:53:26 PM UTC, comment #4:

If you want Octave to execute a *.m file,
just type its name.

Michael Godfrey <godfrey>
Project Member
Sat 29 Sep 2012 10:51:37 PM UTC, comment #3:

Have you tried "help load"
The load command is used for loading a file which contains
Octave data. Do your *.m files contain valid Octave
data?

Michael Godfrey <godfrey>
Project Member
Sat 29 Sep 2012 10:44:32 PM UTC, comment #2:

I simply type "load filename.m" at the prompt. I didn't think any transcript would be useful, because some files load and run OK, but others won't load and I get an error message "unable to determine size of matrix" or other error indicating mismatched rows or columns. Again, these files are in the distribution and when I key them in from the keyboard, they work fine.

Anonymous
Sat 29 Sep 2012 09:40:46 PM UTC, comment #1:

Exactly ho do you invoke those .m files?

Do you have a short transcript from an Octave session showing the errors?

Philip Nienhuis <philipnienhuis>
Project Member
Sat 29 Sep 2012 03:18:26 PM UTC, original submission:

I installed Octave on a Samsung laptop running Windows 7, 64-bit. Many, if not most, of the m files supplied with this distribution abort with errors -- usually failure to determine matrix size, or incompatible matrix dimensions. When I key the same file contents from the keyboard, they work fine. It seems there is some problem in the load file function. Has anyone else seen this problem? Is there some way to modify the files so they read properly?

Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by jwe (Posted a comment)
  • -unavailable- added by jordigh (Posted a comment)
  • -unavailable- added by godfrey (Posted a comment)
  • -unavailable- added by philipnienhuis (Posted a comment)
  • -unavailable- added by None (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 3 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Sun 30 Sep 2012 08:58:01 PM UTCphilipnienhuisStatusNeed Info=>Invalid
      Open/ClosedOpen=>Closed
    Sat 29 Sep 2012 09:40:46 PM UTCphilipnienhuisStatusNone=>Need Info

    Back to the top


    Powered by Savane 3.1-cleanup1