hack of menu.m

Schloegl Alois alois.schloegl at tugraz.at
Tue May 21 14:19:25 CDT 2002


menu does not return selected value but produces error message and repeats
display of the selection. 


octave:3> K = menu('title','s1','s2','s3')
title

  [ 1] s1
  [ 2] s2
  [ 3] s3

pick a number, any number: 1

error: input invalid or out of range

  [ 1] s1
  [ 2] s2
  [ 3] s3



The following hack is a quick solution, not necessarily the best. 


*** /home/schloegl/cvs/octave/scripts/miscellaneous/menu.m      Thu Jan 13
09:40:14 2000
--- /usr/local/share/octave/2.1.36/m/miscellaneous/menu.m       Tue May 21
21:05:45 2002
***************
*** 64,69 ****
--- 64,74 ----
        endfor
        printf ("\n");
        s = input ("pick a number, any number: ", "s");
+
+       ## a hack - removes last character <CR>
+       ## otherwise menu would not work correctly.
+       s = s(1:length(s)-1);
+
        eval (sprintf ("num = %s;", s), "num = [];");
        if (! is_scalar (num) || num < 1 || num > nopt)
          printf ("\nerror: input invalid or out of range\n\n");



-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------




More information about the Bug-octave mailing list