The function getSize() is undefined in this script

[attachment=0]Print_Screen_01034.jpg[/attachment]
I do a foundset.getSize() against a foundSetVariable.

It works (see the console in printscreen) but I have this Error in the editor:

The function getSize() is undefined in this script

Is this expected / not suggested ?

thank you for help

I think Servoy doesn’t recognize the variable as type foundset.
Could you try to at the JSDoc for that?

something like

/** @type{JSFoundset}*/

EDIT: you can also add JSDoc to the global method

@return {JSFoundset}

And if the variable is a custom object?
Can I create new types and add them to the JSDoc?

http://wiki.servoy.com/display/public/D … sing+JSDoc

see things like Object type and so on.

jcompagner:
http://wiki.servoy.com/display/public/DOCS/Annotating+JavaScript+using+JSDoc

see things like Object type and so on.

I had read…
But I think that it isn´t very nice to repeat in each function for example

/**
 * @param {{name:String, age:Number}} pPerson
 *
...

So is it possible to create a new type Person and don´t have to write the object definition?
@param {Person} pPerson ?

mboegem:
EDIT: you can also add JSDoc to the global method

@return {JSFoundset}

This is exactly what I was looking for. Now I understand
this meaning of the JSDoc.

Thank you all for Help !

victor.rojo:
So is it possible to create a new type Person and don´t have to write the object definition?
@param {Person} pPerson ?

Pls. read my post on the @return, this will work for the object you want.

Example of the function creating the object.

/**
 * @param {String} id
 * @return {Object}
 */
function getPerson(id)
{
// the 'id' param maybe used to look up the person...
	var _p = new Object();
	_p.name = 'Marc';
	_p.age = 38;
	
	return _p;
}

Example of the calling method:

function myMethod()
{
	var _p1 = globals.getPerson('abc');
}

you will see that the _p1 variable in de calling method now has autocompletion on ‘name’ and ‘age’.

Hope this helps

It helps when the object is returned by a function, thanks Marc.

But I still have problems if the object is a function param.

Example

/**
* @param {Object} pPerson
*/
function printPerson(pPerson)
{
     application.output(pPerson.name)
     application.output('Is parent? ' + pPerson.isParent())
......
}

In this case I have warnings about the property name and the function are undefined. I can change the param tag to “@param {{name:String, isParent:Boolean, …}} pPerson” but I will have to do it for each function and every time I modify the object.

victor.rojo:
In this case I have warnings about the property name and the function are undefined. I can change the param tag to “@param {{name:String, isParent:Boolean, …}} pPerson” but I will have to do it for each function and every time I modify the object.

I don’t know another way of achieving what you want.
But can’t you re-structure the method?
Just pass the ID of the record, call the function as I explained and return the object…

you can do this:

function Person() {
	this.name = "";
	this.isParent = false;
}

/**
 * @param {Person} person
 */
function myFunction(person) {

}

the only thing is that that works fine in the same scope like globals file or a form file
but if that object has to work over multiply files and scopes it s a bit tricky currently to mix them.

(stuff like {globals.Person} ) but then the return types also must specify that and so on, thats not fully supported yet)

Ok. Thank you. This is what I need!

it sounds as if an “include” file for JSDoc is needed to cover multiple files etc…