Ask a Question

Is there a way to return the name of the current sub routine or function?

Marsha_R
Community Hero

RE: Is there a way to return the name of the current sub routine or function?

I'd like it in keyword tests too please.

Marsha_R
[Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
TanyaYatskovska
Community Manager

RE: Is there a way to return the name of the current sub routine or function?

Hi,

 


I've added your votes. Thanks!


 

---------
Tanya Yatskovskaya
SmartBear Community and Education Manager


Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
Marsha_R
Community Hero

RE: Is there a way to return the name of the current sub routine or function?

Another vote please, so we can do this in keyword tests.

Marsha_R
[Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
Manfred_F
Regular Contributor

RE: Is there a way to return the name of the current sub routine or function?

Hi guys,



a System function for the Routine Name would be nice. We'd also Need a System function for the module Name, of course.



I'd also add my vote.



So far, You could use code templates for vbs modules and routines, which contain predefined constants for the element names, e.g. for a module:



Option Explicit

' ModulKommentar

Const mcModul = "Modulname."



or for a Routine


Function |( _

Par1, _

Par2 _

)

' KommentarFunktion

Const cRoutine = "NameFunktion"

Dim Ergebnis

  

   NameFunktion = Ergebnis

End Function



As a result, I can use the names in the log, e.g.

 



Log.Checkpoint "Tabelle Abbruch abgebrochen", mcModul & cRoutine







Regards,



Manfred

 


TanyaYatskovska
Community Manager

RE: Is there a way to return the name of the current sub routine or function?


Hi,


 


I've added your votes. 


Manfred, thanks for sharing your solution.


 

---------
Tanya Yatskovskaya
SmartBear Community and Education Manager


Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
Alice
Occasional Contributor

Re: RE: Is there a way to return the name of the current sub routine or function?

Please add my vote as well!

katven
New Contributor

Re: Is there a way to return the name of the current sub routine or function?

+1 for this feature. 

 

Kindly add my vote too. 

Using TC10.50
TanyaYatskovska
Community Manager

Re: Is there a way to return the name of the current sub routine or function?

Hi,

Thanks for your requests! Now, we have a special place in the Community where our users can submit their ideas or vote for the ideas they like. I’ve found a similar idea that has already been submitted. You can vote it up.

http://community.smartbear.com/t5/TestComplete-Feature-Requests/have-access-to-the-name-of-the-curre...

 

 

TestComplete’s PO monitors this forum on a regular basis, and uses this information for development planning.

---------
Tanya Yatskovskaya
SmartBear Community and Education Manager


Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
anik_cadieux
Contributor

Re: Is there a way to return the name of the current sub routine or function?

I am also trying to figure out a way to know the current script name. We are launching TestExecute with Bamboo using command line. I think we can use 

BuiltIn.ParamStr
meinTest
Occasional Contributor

Re: Is there a way to return the name of the current sub routine or function?

For JavaScript, I found the following workaround. Maybe it will help others.

I create a try-catch block. Within the try I provoke an exception, this one I catch-up with the catch and read-out the function name in the stack.

 

Note: this also works across several units -> USEUNIT

function getCaller(){
  let arrStackLines = [];

  try{
    throw new Error("throw a error to get the stack");
  }catch(objE){
    arrStackLines = objE.stack.split("\n");
  }
  let strLine = arrStackLines[arrStackLines.length -1];
  let intStart = strLine.indexOf("at ") + 3;
  let intEnd = strLine.indexOf("(<");
  Log.Message(strLine.substring(intStart, intEnd));
}

 

Btw. please add my vote..:-)

 

Best regards 

 

sign.png

  meinTest GmbH

  www.meinTest.software

 

 SmartBear preferred value-added Service

 Provider in the DACH region

cancel
Showing results for 
Search instead for 
Did you mean: