Jump to content

How to get a function name


Recommended Posts

I don't see th reason for this, but I guess you could create a local variable inside each function and define the function name there... that way you should be able to retrieve it..

Thanks, but I need it dynamics since I am creating dynamics au3 scripts with dynamics functions

Be Green Now or Never (BGNN)!

Link to comment
Share on other sites

How do you have dynamic functions? If you are using Call(), the functions are still predefined. If you are using /AutoIt3ExecuteLine, you still are using known function names.

In PHP there is a global constant I think called __FUNCTION__, but PHP offers variable functions. Maybe there is something similar hidden in AutoIt. I have never used this in PHP but I have used get_class() which is nice.

Link to comment
Share on other sites

What is a dynamic function?

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

What is a dynamic function?

LOL, I guess your concept is very strange. Use one function which acts different with different parameters.

Mega

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

This is effectively the same as Call():

<?php

function foo() {

echo "In foo()<br />\n";

}

function bar($arg = '')

{

echo "In bar(); argument was '$arg'.<br />\n";

}

// This is a wrapper function around echo

function echoit($string)

{

echo $string;

}

$func = 'foo';

$func(); // This calls foo()

$func = 'bar';

$func('test'); // This calls bar()

$func = 'echoit';

$func('test'); // This calls echoit()

?>

Link to comment
Share on other sites

  • 4 years later...

Has such a feature been added in the time since this topic was created ?

I could not find any update info, but you never know.

I don't see th reason for this, but I guess you could create a local variable inside each function and define the function name there... that way you should be able to retrieve it..

A reason for wanting this is to put the function name in front of error log messages...

(and adding a local variable to each function becomes a bit of a PITA :( )

Link to comment
Share on other sites

No, such a feature hasn't been added, and adding a single variable with its contents being the name of the funtion it's in isn't that hard, just a LITTLE time consuming if you're adding to an existing script.

Although you could probably modify the SciTE tool that adds function trace lines to a script to have it create the local variable instead of a consolewrite. The tool's code is in AutoItTools.lua.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

  • 1 month later...

No, such a feature hasn't been added, and adding a single variable with its contents being the name of the funtion it's in isn't that hard, just a LITTLE time consuming if you're adding to an existing script.

Although you could probably modify the SciTE tool that adds function trace lines to a script to have it create the local variable instead of a consolewrite. The tool's code is in AutoItTools.lua.

Exactly what I done at one point, you could also write a quick script to add them, but I'd personally love to see (and I know new macros are on the not to do list) @FunctionName.

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...