Dynamically Calling a Function that is included

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Terka
Posts: 157
Joined: 05 Nov 2015, 04:59

Dynamically Calling a Function that is included

21 Nov 2017, 08:06

when Dynamically Calling a Function

Code: Select all

runfunction:="mb"
      %runfunction%()
runmb()
{
  mb()
return
}
mb()
{
msgbox hello
return
}
it does not work if the function mb() is included, but if its in main code without inclusion, it works.
Any suggestions please?
A_AhkUser
Posts: 1147
Joined: 06 Mar 2017, 16:18
Location: France
Contact:

Re: Dynamically Calling a Function that is included

21 Nov 2017, 23:00

Hi Terka,

It is question of dynamically calling a function that is intended to be auto-included. Yet, in this case, the documentation indicates:
Only a direct function call such as MyFunc() can cause a library to be auto-included. If the function is only called dynamically or indirectly, such as by a timer or GUI event, the library must be explicitly included in the script. For example: #Include <MyFunc>
source: Libraries of Functions: Standard Library and User Library
my scripts
burque505
Posts: 1736
Joined: 22 Jan 2017, 19:37

Re: Dynamically Calling a Function that is included

22 Nov 2017, 12:12

Hi Terka, I'm hoping the code I'm attaching will help. In your code, %runfunction%() is going to call mb(), not runmb(), which I didn't quite understand, because it bypasses runmb().
Spoiler
This calls the following code (mb.ahk) by inclusion (#Include mb.ahk, in the same directory:
Spoiler
I hope this helps a little. I often have trouble with the docs for AHK myself, and this case is no exception.

Regards,
burque505

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: badkarma5150, Spawnova and 288 guests