From: Antonio l. <ald...@gm...> - 2013-10-21 08:23:07
|
Hi Kay, You are right, the issue was that. I'm newbie in Javascript, and couldn't find any example of format() that explained that error. Best regards and many thanks. Antonio 2013/10/18 Kasemir, Kay <kas...@or...> > Hi: > > I assume that's related to Formatter.format() expecting arguments (String, > Object[]), since it's a Java var-arg function. > Have you tried to call it like this: > > var line = f.format("%4$2s %3$2s %2$2s %1$2s", [ "a", "b", "c", "d" ]); > > May need to use something else to create a Java Object[] array from [ "a", > "b", "c", "d" ]. > > -Kay > > On Oct 18, 2013, at 6:25 AM, Antonio lopez <ald...@gm... > <mailto:ald...@gm...>> wrote: > > Dear Colleagues, > > We are writting the next javascript code, embedded in a OPI button: > > importPackage(Packages.org.csstudio.opibuilder.scriptUtil); > importPackage(Packages.java.lang); > importPackage(Packages.java.util); > > var sb = new StringBuilder(); > var f = new Formatter(sb, Locale.US); > f.flush(); > var line = f.format("%4$2s %3$2s %2$2s %1$2s", "a", "b", "c", "d"); > > > and we are getting the error that the format funtion can't find. > > 2013-10-18 11:56:53 ERROR: Error exists in script null > Can't find method > java.util.Formatter.format(string,string,string,string,string). (script#8) > > Does somebody know the reason of this? we need the format function to give > format to some values to a string. > > Thanks in advance. > > |