Sun 01 May 2016 07:00:53 PM UTC, original submission:
This works:
fid = fopen ("foo.m", "wt");
fputs (fid, "function foo ()\n disp (\"This is function foo.\");\nendfunction\n");
fclose (fid);
fn = str2func ("foo");
fn ()
This doesn't:
addpath("C:\example)
fid = fopen ("C:\example\foo.m", "wt");
fputs (fid, "function foo ()\n disp (\"This is function foo.\");\nendfunction\n");
fclose (fid);
fn = str2func ("foo");
fn ()
That is because Octave doesn't refresh the functions in others directories, only the current path.
This is something that rehash would fix... right?
This fails too:
fid = fopen ("foo.m", "wt");
fputs (fid, "function foo ()\n disp (\"This is function foo.\");\nendfunction\n");
fclose (fid);
rehash()
fn = str2func ("foo");
fn ()
Using ignore_function_time_stamp doesn't fix it:
ignore_function_time_stamp("none")
fid = fopen ("foo.m", "wt");
fputs (fid, "function foo ()\n disp (\"This is function foo.\");\nendfunction\n");
fclose (fid);
fn = str2func ("foo");
fn ()
If I wait a while (like 1 min or something like that), I can do the str2func and works fine.
(Windows, no packages installed, octave 4 clean)
Maybe #35771 is related.
|