Get Method Name?

Questions, tips and tricks and techniques for scripting in Servoy

Get Method Name?

Postby chico » Thu Jul 23, 2009 9:39 pm

I want to get better information on our error logs, specifically, be able to get the name of the method (if any) that was running when the error occured.

Is there a command, plugin, tool, wish... anything you can do to grab the name of the currently active method?

Thanks,

chico
--------------------------------------------
Servoy Version: 6.0.3
DB: MySQL 5.1
Win XP/Vista/7 - Java 5u20 / 6u22
OS X - 10.6.5 - Java 5/6 update 3
chico
 
Posts: 271
Joined: Tue Nov 20, 2007 6:34 am

Re: Get Method Name?

Postby jcompagner » Mon Aug 03, 2009 10:53 am

at what point do you want to get that info?
like in a try/catch?

But if you have the try/catch then you already know the method you are in.
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 7977
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet

Re: Get Method Name?

Postby juan.cristobo » Thu Feb 25, 2016 12:01 pm

I'd like to get the method name inside it, i.e.:
Code: Select all
function aMethod()
{
    application.output('The name of this method is:' + ????)
}


Of course, I know the method name now, but if I change it, I have to remember to change the code too.
Juan
Madrid (Spain)

Servoy 7.4.x - MySQL / SQL Server 2008-2016
Windows 10 Pro
juan.cristobo
 
Posts: 178
Joined: Thu Apr 19, 2012 9:12 am

Re: Get Method Name?

Postby steve1376656734 » Thu Feb 25, 2016 6:43 pm

Hi Juan,

I use the following code to get both the form name and method name:
Code: Select all
   /** @type {String} */
   var methodName = controller.getName() + "." + arguments['callee'].name;


but just the last part will give you the method name on it's own.

Hope this helps
Steve
Steve
SAN Developer
steve1376656734
 
Posts: 180
Joined: Fri Aug 16, 2013 2:38 pm
Location: Lanzarote

Re: Get Method Name?

Postby juan.cristobo » Thu Feb 25, 2016 6:58 pm

Thanks, Steve, I found that code, but Servoy shows a warning:
Code: Select all
Event parameter is passed to event method; make sure it is used with right type (change method signature).

So I don't know if that code is a good practice :wink:
Juan
Madrid (Spain)

Servoy 7.4.x - MySQL / SQL Server 2008-2016
Windows 10 Pro
juan.cristobo
 
Posts: 178
Joined: Thu Apr 19, 2012 9:12 am

Re: Get Method Name?

Postby steve1376656734 » Thu Feb 25, 2016 7:09 pm

That's odd as I definitely don't get that warning - I am running Servoy 7.4.6
Steve
SAN Developer
steve1376656734
 
Posts: 180
Joined: Fri Aug 16, 2013 2:38 pm
Location: Lanzarote


Return to Methods

Who is online

Users browsing this forum: No registered users and 3 guests