tor, 15 04 2010 kl. 16:36 +0200, skrev Sascha Raddatz:
> i've got a matlab-file which i want to use with octave. octave seems not
> to know the function 'uigetfile'. how can i else open a textfile to read
> its content into octave?
The functions 'textread' and 'load' might be of use to you.
I took the liberty to slightly enhance it with a call to zenity (gnome dialogs) to complement kdialog. Also, the fall back solution now uses 'dir' which is platform independent, and thus will work on all systems.
Shuold it be contributed to the octave sourceforge ?
> I took the liberty to slightly enhance it with a call to zenity (gnome
> dialogs) to complement kdialog.
> And here is the uigetfile using dir, or zenity or kdialogs, which should
> work on all systems.
Unfortunately zenity does not work properly:
A1. uigetfile('*.dat', 'Open data file')
=> it ignores the '*.dat' filter. Even if I try it from command line
zenity --file-selection --filename='*.dat'
then the filter is ignored.
Is that a bug in zenity? If it is, then zenity has to be the last
B. Further, you have removed the case of "xdialog". I think it is available
on (older) systems without KDE and Gnome ... cygwin/X11, for example.
Please revert it.
C. Further, you have removed lines such as
[a,b]=system('which XXXXdialog 2>/dev/null');
and thus yet another annoying messages appear such as:
sh: zenity: command not found
I think it should be reverted.
BTW -- is this "which" available in cygwin-Octave?
D1. Your plain text "dir" is cool, but produces wrong output for files:
D2. uigetfile('*.dat', 'Open data file')
produces error message:
error: ui: A(I): index out of bounds; value 3 out of bound 2
Could you please update the patch?
> Should it be contributed to the octave sourceforge?
A: zenity is now third choice, and indeed the filter is not functional (unfortunately). On the other hand, launching Kdialog from a non KDE systems takes quite some time. The warning is not shown as a '2>/dev/null' redirection is there.
B: Xdialog is indeed very good, thus I put it back.
C: I fixed the warning (from stderr) displayed when some of xdialog/kdialog/zenity is not installed. I thus re-introduced the '2>/dev/null' redirection in command lines.
D: the 'dir' now works OK, aa a check for existence of files to select is done prior to anything else. Trailing filesep have been removed.
I hope we now converge to something both portable and fancy .