Subj : Re: vector as return type in java function - access in jscript? To : Ulrich Staudinger From : Igor Bukanov Date : Wed Jan 28 2004 12:45 am Ulrich Staudinger wrote: > hi, > > ---------------------- jscript: > 10: function initialize(){ > 11: var v=dbl.getTenMinuteCandles(10); > 12: var c= new Packages.Candle(); > 13: xp.sendChatMessage("uls@jabber.org", "initialize."+c.getClose()); > 14: var value=0.0; > 15: for(i=0;i<10;i++){ > 16: c=v.elementAt(i); > 17: > 18: > 19: value+=c.getClose(); > 20: } > 21: xp.sendChatMessage("uls@jabber.org", "initialize."+value); > 22: } > ------------- > > i call the jscript function from a class evaluator. 'dbl' is known to > the interpreter, as is xp. i can instantiate the new Packages.Candle(). > Now, whenever i try to call c.getClose(), rhino responds with > 'TypeError: undefined is not a function. (; line 19)' > > The vector should not be empty, i know that values are returned. the > call in line 13 works. Are you sure that v contains instances of Candle? Try to add something like java.lang.System.out.println(c + " "+typeof c+" "+c.getClass()) after the line 16. > > Do i have to cast to type Candle in line 16? Am i doing something wrong? JS has no casts, it is dynamically typed language after all... Regards, Igor .