What are limits of Servoy's JavaScript Implementation?
Posted:
Wed Sep 13, 2006 10:51 am
by konsta
I've seen try/catch referred to on this forum, but I have not been able to get it to work reliably in Servoy Beta v. 3 RC4. I've also noticed that not all functions (e.g. toString() ) are available. Is there a listing of what features of JavaScript are unavailable?
Also, if anyone can point me in the direction of documentation regarding SOM, I would greatly appreciate it. I have spent a fair amount of time trying to get a listing of all forms and their elements using associative arrays, but I keep running into errors. I'm trying to get a good handle on the object model and I keep running into problems that I can't get around.
Can anyone suggest a resource?
---Andrew
Posted:
Wed Sep 13, 2006 1:09 pm
by IT2Be
Hi,
Imho
- Code: Select all
try {} catch {
works but doesn't always throw an error where you expect it.
toString() works, try this
- Code: Select all
var number = 13;
application.output(number.toString());
A lost of the available JS functions are listed under JS Lib.
A good source would by my Pre-Servoy World class
Posted:
Wed Sep 13, 2006 5:04 pm
by konsta
Hmm, my problem with try/catch is that I'm still getting an method-terminating error when I use it (a bizarre one, in fact, I'm getting an out-of-bounds array reference when I am at j = 2 while looping through an object whose associative array has a length of 40.
I have not tried .toString() for converting numbers to strings (since loosely typed languages do that for me). I usually use .toString() to identify a variable's type (e.g. string, integer, object, etc.).
Perhaps you can help me in my ultimate goal, which is to loop through all objects in a solution to find out their properties (both names and values). If anyone has an idea how I can (programatically) get all the methods/functions as well, that would be great.
When I have used JavaScript techniques that have worked in different environments, I get errors. For example, I can't seem to pass a form as an argument to a global method - to get around it, I pass the form name and access the form inside the method by referring to it via forms['name'].
This approach only takes me so far, as I try to iterate through a form's properties using the same approach (e.g. object[propertyname]), I invariable run into an error of one type or another. First I tried checking to see if the property is null before printing it in the loop, which seemed to work sometimes, but still didn't solve the error problem. Then I attempted to use try/catch, which just created another error (this time, one I can't seem to understand, as I explained above).
Perhaps what I am trying to do is not possible without writing a plugin. At the end of the day, what I would like to see is a complete description of the objects in the Servoy Object Model. Once I have this (or rather, know how to get it, I should be able to get a listing of all the objects and their values in a solution).
If it would be helpful, I am happy to post the code I am using for this as well as the output that gets produced.
Again, any guidance is much appreciated.
---Andrew
P.S. I am using the CRM app provided with Servoy as my testbed.