Re: load problems

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: load problems

Joao Cardoso-3
"John W. Eaton" wrote:
>
> On  2-Aug-2000, Ben Sapp <[hidden email]> wrote:
>

...

> Of course, Octave should probably also allow
>
>   x = load ("some-odd-file-name.dat")
>
> so all of this would be unnecessary.  Anyone care to implement it and
> submit a patch?
>
> jwe

Sure.

But making

   x = load ("some-odd-file-name.dat")

can be confusing; one could think that it is a general sintax. Instead,
why not use the standard sintax,

 - Command: load options file v1 v2 ...
     Load the named variables from the file FILE.

using v1 as the name of the variable to load to?

The included patch, for octave 2.1.31,  was made with a contex diff of 6
lines, as I have my other load-save patch in my sources.

To compile I had to use the '-fpermissive' option to gcc. Even so:

load-save.cc: In function `class octave_value_list do_load(istream &,
const   string &, bool, load_save_format, oct_mach_info::float_format,
bool, bool, bool,  bool, const string_vector &, int, int, int)':
load-save.cc:3067: warning: assignment to `char *' from `const char *'
discards qualifiers

ah, how I hate C++! But I'm not a programmer, just a quick hacker!
(cat|asm :-)

Joao

load-save.cc.patch (2K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: load problems

John W. Eaton-6
On  3-Aug-2000, Joao Cardoso <[hidden email]> wrote:

| "John W. Eaton" wrote:
| >
| > On  2-Aug-2000, Ben Sapp <[hidden email]> wrote:
| >
|
| ...
|
| > Of course, Octave should probably also allow
| >
| >   x = load ("some-odd-file-name.dat")
| >
| > so all of this would be unnecessary.  Anyone care to implement it and
| > submit a patch?
| >
| > jwe
|
| Sure.
|
| But making
|
|    x = load ("some-odd-file-name.dat")
|
| can be confusing; one could think that it is a general sintax. Instead,
| why not use the standard sintax,

  load ("file", "option-1", "option-2");

is entirely equivalent to

  load file option-1 option-2

and works for all functions that can be invoked this way (i.e., ls,
type, who, and so on).

|  - Command: load options file v1 v2 ...
|      Load the named variables from the file FILE.
|
| using v1 as the name of the variable to load to?

Because I would think that it means load only the variables named v1,
v2, etc. from the file?

| To compile I had to use the '-fpermissive' option to gcc. Even so:
|
| load-save.cc: In function `class octave_value_list do_load(istream &,
| const   string &, bool, load_save_format, oct_mach_info::float_format,
| bool, bool, bool,  bool, const string_vector &, int, int, int)':
| load-save.cc:3067: warning: assignment to `char *' from `const char *'
| discards qualifiers

Probably you should pay attention to such warnings.  I haven't checked
your code, but discarding const is probably not what you really want
to do.

jwe


Reply | Threaded
Open this post in threaded view
|

Re: load problems

Joao Cardoso-3
In reply to this post by Joao Cardoso-3
> On  3-Aug-2000, Joao Cardoso <[hidden email]> wrote:

>
> | "John W. Eaton" wrote:
> | >
> | > On  2-Aug-2000, Ben Sapp <[hidden email]> wrote:
> | >
> |
> | ...
> |
> | > Of course, Octave should probably also allow
> | >
> | >   x = load ("some-odd-file-name.dat")
> | >
> | > so all of this would be unnecessary.  Anyone care to implement it and
> | > submit a patch?
> | >
> | > jwe
Another try. Please check the docs wording.

Joao

PS-sorry, the enclosed patch also contains my structures/lists save/load
patch

 - Command: load options file v1 v2 ...
     or
       `load("option_1",..., "file", "v1", "v2" ,...)'
     or
        [..., num] = load ...'
...
     If using the third syntax of `load', the specified return variables
     will be used to hold the loaded values. Variables will be loaded
     in order until the return list is exausted. NUM hold the number of
     sucessefully loaded variables.

          [a, b, c, num] = load("foo.dat", "x1", "y", "x3")
         
          gives, if "foo.dat" has variables X1, X2, X3 with values
`1,2,3'
         
          a = 1
          b = [](0x0)
          c = 3
          num = 2

     Wildcarding the argument variables overwrites the corresponding
     output variable, e.g. `[a, b, c, num] = load("foo.dat", "x*")'
     will return only variable A with the last X* variable found, but
     NUM will report that 3 variables has been loaded.

load-save.cc.patch (16K) Download Attachment