Modify

Opened 10 years ago

Last modified 8 months ago

#2833 assigned Feature Request

macro @funcname

Reported by: anonymous Owned by: Jon
Milestone: Component: AutoIt
Version: Severity: None
Keywords: Cc:

Description

Please add a macro, variable or something else that will contain the name of the current function.
This is useful for debugging

Func Test($param, $from_line = @ScriptLineNumber)
	ConsoleWrite('Executing function: ' @funcname & ' calling from ' & $from_line & ' line' & @CRLF)

EndFunc

Attachments (0)

Change History (10)

comment:1 follow-up: Changed 10 years ago by mLipok

Some time ago I made to this functionality, my own solution.
Maybe from here also shows a large number of issue found by me, I just have a good additional diagnostic tools of my own scripts.

But the native solution sounds promising.

comment:2 Changed 10 years ago by Jpm

  • Type changed from Bug to Feature Request

comment:3 Changed 10 years ago by TicketCleanup

  • Version 3.3.12.0 deleted

Automatic ticket cleanup.

comment:4 Changed 10 years ago by BrewManNH

There is a tool in the Tools menu in Scite, if you've installed the full version of SciTE4AutoIt3, that allows you to add a function trace line to every function, you might be able to modify that to create a variable instead of the ConsoleWrite line that it does now.

comment:5 Changed 8 years ago by Zinthose

I'm surprised this hasn't been added yet.

I'm working on some pretty insane deep nested functions and was trying to do something like This:

If IsString($Variable) And IsDeclared($Variable) Then
  Return Execute(@FuncName & "($" & $Variable & ")")
EndIf

This is to address an issue when resolving a variable name using Eval from a global array. The problem is any changes are saved to the local copy made with Eval and not the original variable from the global scope.

I guess ideally I'd like to see Eval have a ByRef parameter to address my issue but I'd still like to see @FuncName implemented.

comment:6 Changed 8 years ago by jchd18

If this is ever considered for actual implementation I believe that a macro @CallStack would be even more useful, returning an array of functions called in decreasing depth order (LIFO mode).
If the associated overhead is going to block making that real, perhaps it's time to have an Opt() switching that on for those who need it.

comment:7 Changed 8 years ago by BrewManNH

Zinthose, I think you misunderstood the request or you're trying to implement it in the worst way possible.
What the request is asking for is to have a macro that tells you the currently executing function, which I don't think would be at all useful because it's just as easy to include a variable set to the name of the function to do exactly the same thing, but would require a coder to have to think for themselves.
Your request is trying to rerun the current function. I'm not sure of what you think you're attempting, but I don't see that as a smart way to do it.

comment:8 in reply to: ↑ 1 Changed 4 years ago by mLipok

Replying to mLipok:

But the native solution sounds promising.

My 2 cents after 6 year of thinking: I do not think that @funcname is necesary.

btw.
Similar closed requests are here:
https://www.autoitscript.com/trac/autoit/ticket/3766
https://www.autoitscript.com/trac/autoit/ticket/2963

Last edited 4 years ago by mLipok (previous) (diff)

comment:9 Changed 4 years ago by Jpm

  • Owner set to Jpm
  • Status changed from new to assigned

Hi, I sent a fix to Jon
the macroname is @ScriptFuncName

comment:10 Changed 8 months ago by Jpm

  • Owner changed from Jpm to Jon

Guidelines for posting comments:

  • You cannot re-open a ticket but you may still leave a comment if you have additional information to add.
  • In-depth discussions should take place on the forum.

For more information see the full version of the ticket guidelines here.

Add Comment

Modify Ticket

Action
as assigned The owner will remain Jon.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.