ServoyForge COM plugin sending Real not Integer

Questions and answers on developing, deploying and using plugins and JavaBeans

ServoyForge COM plugin sending Real not Integer

Postby joe26 » Mon Aug 27, 2018 6:09 pm

Good Day!

Is anyone using COM in their solution?

My issue, already ticketed under ServoyForge #1364, is that the COM bridge isn't resolving the integer argument I send. Instead the receiving COM server gets a Real number.

The COM server is particular about a database name versus a database index. If the index is not an integer, it is resolved to be a String which locates the database name, based on the index passed into the COM Server, from the COM bridge which is a Real number. There is no database name represented by the generated Real number index string.

If an index is specified as an integer, always an integer 1 in my case, the COM Server gets 1.000000, and says database 1.000000 cannot be found.

If an index is specified as a String, '1', the COM Server generates the 'cannot find database 1' error.

If an existing database name is entered, then it returns the database object for that name. Yup, that one works.
=>DBs.getChildJSCOM('GetDataBase','',['barcodelabel'])
com.servoyguy.plugins.servoycom.RemoteCOM@52f8cb16

if a (bad) index number of 1.2345678910 is provided, then the database '1.234567' cannot be found.

if a non-existent database name of 1.234567890 is provided, then the database '1.234567890' cannot be found.

That's why it is convincing the Int_to_Real and Real_to_String issue occurs.

It was suggested that a suitable package be sent that can resolve to the integer.
I've tried numerous casting methods to force the input to be an Integer. Among the responses:

=>DBs.getChildJSCOM('GetDataBase',[new Packages.java.lang.Integer(1)])
null
=>DBs.getLastError()
"com.jacob.com.NotImplementedException: populateVariant() not implemented for class org.mozilla.javascript.NativeNumber"
=>

=>DBs.call('GetDataBase',new Packages.java.lang.Integer(1))
null
=>DBs.getLastError()
"com.jacob.com.NotImplementedException: populateVariant() not implemented for class org.mozilla.javascript.NativeNumber"

=>DBs.getChildJSCOM('GetDataBase','',[new Packages.java.lang.Integer(1)])
null
=>DBs.getLastError()
"com.jacob.com.NotImplementedException: populateVariant() not implemented for class org.mozilla.javascript.NativeNumber"

=>DBs.getChildJSCOM("GetDatabase",'',[Math.ceil('1')])
null
=>DBs.getLastError()
"com.jacob.com.ComFailException: Invoke of: GetDatabase
Source: BarTend
Description: Cannot find database 1.000000.
"

It may be that the COM bridge needs an argument of type Variant.VariantInt.. Sending something cast to a Number fails since the arguments reject the type Number as an argument type.

I'm working on that part.

has anyone else seen this behavior?

thanks,
Joe.
joe26
 
Posts: 172
Joined: Wed Jun 19, 2013 10:30 pm

Re: ServoyForge COM plugin sending Real not Integer

Postby joe26 » Mon Aug 27, 2018 10:09 pm

In addition, while in the console, typing

=>someVariable = 1
1.0
=>someVariable = 2
2

Is this normal?

There will never have more than an index of 1 into the label database above. So index = 2 cannot be tested.

If the environment is always giving me a Real number for an integer 1, how is an integer to be passed into any call in the COM bridge?

Also, there's no way of knowing why an integer of two is returned as a 'database not found' by the COM server unless it becomes an invalid index, so an additional attempt is made as a String entry repping as a database name...

Does anybody have a similar result? Maybe my install is quirked somehow?
joe26
 
Posts: 172
Joined: Wed Jun 19, 2013 10:30 pm

Re: ServoyForge COM plugin sending Real not Integer

Postby joe26 » Mon Aug 27, 2018 10:44 pm

That might not be the case either...

=>m = [0,1]
[0.0,1.0]
=>m.indexOf(1)
1
=>DBs.call('GetDatabase',m.indexOf(1))
null
=>DBs.getLastError()
"com.jacob.com.ComFailException: Invoke of: GetDatabase
Source: BarTend
Description: Cannot find database 1.000000.
"
So it is being passed an integer, but still changed to Real.

In the code, the check for a Real value is done prior to the Integer value, but the Real test should have thrown an error and proceeded onto the next try...catch following it.

Code: Select all
        public JSVariant(final Object o){
                //        should always cast : put in here for reflection
                final Variant v = (Variant)o;
                if(v.isNull()){
                        isNull = true;
                        return;
                }
                try{
                        stringValue = v.toString();
                        isString = true;
                }catch(final Throwable t){}
                try{
                        doubleValue = v.changeType(Variant.VariantDouble).getDouble();
                        isDouble = true;
                }catch(final Throwable t){}
                try{
                        intValue = v.changeType(Variant.VariantInt).getInt();
                        isInt = true;
                }catch(final Throwable t){}
                try{
                        booleanValue = v.changeType(Variant.VariantBoolean).getBoolean();
                        isBoolean = true;
                }catch(final Throwable t){}


and nothing with this call either:

=>DBs.getChildJSCOM('GetDatabase',[m.indexOf(1)])
null
=>DBs.getLastError()
"com.jacob.com.ComFailException: A COM exception has been encountered:
At Invoke of: GetDatabase
Description: The parameter is incorrect.
"
No way to know if the Integer 1 made it through to the COM server or the COM bridge. My thinking is COM bridge.
joe26
 
Posts: 172
Joined: Wed Jun 19, 2013 10:30 pm


Return to Plugins and Beans

Who is online

Users browsing this forum: No registered users and 9 guests