octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #41931] listdlg returns Java object int[] rath


From: Philip Nienhuis
Subject: [Octave-bug-tracker] [bug #41931] listdlg returns Java object int[] rather than an integer
Date: Sat, 22 Mar 2014 15:09:49 +0000
User-agent: Mozilla/5.0 (Windows NT 5.1; rv:25.0) Gecko/20100101 Firefox/25.0 SeaMonkey/2.22.1

Follow-up Comment #1, bug #41931 (project octave):

This goes back to at least OF Java package 1.2.8

With octave-3.4.3 & 3.6.4 (both MinGW):
octave:1> [sel, ok] = listdlg ("Liststring", {"One", "Two", "Three"})
...<selecting "Two", clicking OK>
sel =

<Java object: int[]>

ok =  1
octave:2>  {"One", "Two", "Three"}(sel(1))
ans =
{
  [1,1] = Two
}
octave:3> numel (sel)
ans =  1
octave:4> [sel, ok] = listdlg ("ListString", {"One", "Two", "Three"},
"SelectionMode", "Multiple")
...<selecting "One" and "Three", clicking OK>
sel =

<Java object: int[]>

ok =  1
octave:5> numel (sel)
ans =  2
octave:6>  {"One", "Two", "Three"}(sel(1))
ans =
{
  [1,1] = One
}
octave:7>  {"One", "Two", "Three"}(sel(2))
ans =
{
  [1,1] = Three
}


It isn't straightforward to cast (box) sel into an Octave class:


octave:8> javamethods (sel)

{
  [1,1] = void wait(long) throws java.lang.InterruptedException
  [1,2] = void wait() throws java.lang.InterruptedException
  [1,3] = void wait(long, int) throws java.lang.InterruptedException
  [1,4] = boolean equals(java.lang.Object)
  [1,5] = java.lang.String toString()
  [1,6] = int hashCode()
  [1,7] = java.lang.Class getClass()
  [1,8] = void notify()
  [1,9] = void notifyAll()
}


but as sel can be used for indexing, something along the lines of:
tmp = zeros (numel (sel))
for ii=1:numel (sel)
tmp(ii) = sel(ii);
endfor

gives the desired pointers into ListString.

BTW, the example in listdlg.m isn't at variance with the the bug report and
the above observations. Nowhere is it literally stated that sel is an Octave
integer. But obviously that is what unwary users would expect.


Another observation:
The actual listing of "One Two Three" doesn't appear on screen unless
ListString is in camelcase; IOW the list of choices is empty. Similar holds
for other key names. 
I'd rather prefer case-insensitive key names. Easily done by morphing the
strcmp calls into strcmpi.


Changeset attached for both "issues" 


(file #31005)
    _______________________________________________________

Additional Item Attachment:

File name: listdlg_41931.cs               Size:1 KB


    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?41931>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]