Is there a way to evaluate if a certain method exists?

I need to evaluate if a certain method exists in a certain form, I tried with this code:

var formName = application.getMethodTriggerFormName(); // get the form name

if ( eval(forms[formName].method()) ) // evaluate if the method exists
{
	forms[formName].method();	// run the method
}
else { ... }

It works if the method exists and if it returns true to the eval() function but it obviuosly doesn’t work if the called method doesn’t exists.
Is there another way to check if a method is there?

good point!

very handy when working with modules!

HJK:
good point!

very handy when working with modules!

The issue arised from a module I’m working on, my goal is to define some default methods in the module and evaluate if there is a more specific method in the main solution at runtime, if there’s not a specific method then the default one from the module is used.

Same logic can be applied to forms:

if in the main app there is a form called [xxx] show that form otherwise remain in the current one or do {whatever}

This is quite easy by evaluating() foundset.getSize for the supposed form, maybe it will not work in every situation but it is a good starting point.
But when talking about methods I can’t find a way to check if there is a valid method with that name in that particular form.

Should I post a feature request?

Here is your method:

if (forms["formName"].method) {
	application.output("existing method");
} else {
	application.output("non existing method");
}
  1. The test ALWAYS NEEDS the forms.formname or forms[“formName”] in front of the name of the method (javascript thing);
  2. When you evaluate with () you don’t evaluate but execute!!! So leave them away (sorry I think their name is parenthesis but I am not sure :( );
  3. eval() is not necessary;

Hope this helps

IT2BE:

  1. The test ALWAYS NEEDS the forms.formname or forms[“formName”] in front of the name of the method (javascript thing);
  2. When you evaluate with () you don’t evaluate but execute!!! So leave them away (sorry I think their name is parenthesis but I am not sure :( );
  3. eval() is not necessary;

Hope this helps

Beg your pardon, Sir.
:oops:

These are the posts that makes this forum great!
I owe u a beer, look for me at ServoyWorld, I’ll be the one with a box of beers on my back… :D

Jokes apart, thanks! I really couldn’t figure out what was wrong and there was a lot of wrong things…

Hmm, that beer is always welcome but even without the beer it is more than just fun to make other people happier this way.

BTW, now that I think of it, bring the beer :) just look for somebody hanging around completely drunk and its me :D

IT2BE:
BTW, now that I think of it, bring the beer :) just look for somebody hanging around completely drunk and its me :D

Ok, I’ll keep my eyes open for a drunk developer hanging around…
And when I’ll find you someone will have to look for 2 drunks developers hangin around… :D

Beer you there!

ngervasi:

IT2BE:
BTW, now that I think of it, bring the beer :slight_smile: just look for somebody hanging around completely drunk and its me :smiley:

Ok, I’ll keep my eyes open for a drunk developer hanging around…

It’s going to be like looking for a needle in a haystack… :wink: