get name of include file

Get help with using AutoHotkey and its commands and hotkeys
User avatar
SL5
Posts: 875
Joined: 12 May 2015, 02:10
GitHub: sl5net
Contact:

get name of include file

27 Feb 2018, 07:52

I have long ago created a workaround for this problem. A precompiler that regularly scans my include files and hardcoded the addresses in those places. But of course I do not always have this script with me and of course I would prefer a more elegant solution. An idea?
Besides, my solution is not bidirectional, not very flexible. If I change the name of the include file, the entries are not updated automatically. Of course you could also program it into the precompiler ...

BTW: https://www.google.de/search?q=autohotk ... ncludefile
User avatar
jeeswg
Posts: 6904
Joined: 19 Dec 2016, 01:58
Location: UK

Re: get name of include file

27 Feb 2018, 08:49

To get a list of all included files (if that's what your asking), I might do something like this. Add this function to all files, but with a different name each time.

Code: Select all

Inc1()
{
	static vDummy := Inc1()
	;static vDummy := %A_ThisFunc%() ;doesn't work
	global oInc
	if IsObject(oInc)
		oInc.Push(A_LineFile)
	else
		oInc := [A_LineFile]
}
And then to retrieve the filenames:

Code: Select all

q::
vOutput := ""
for vKey, vValue in oInc
	vOutput .= vKey " " vValue "`r`n"
MsgBox, % vOutput
return
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
gregster
Posts: 3377
Joined: 30 Sep 2013, 06:48

Re: get name of include file

27 Feb 2018, 08:53

Delta Pythagorean wrote:A_LineFeed I think is what you're wanting.
There is A_LineFile, but no A_LineFeed.
User avatar
SL5
Posts: 875
Joined: 12 May 2015, 02:10
GitHub: sl5net
Contact:

Re: get name of include file

27 Feb 2018, 09:28

A_LineFile
YES :bravo: thats it!! thanks all! :) i not believed it!!! is this a new feature?

Code: Select all

ScriptNameLine := % SubStr(A_LineFile,InStr(A_LineFile,"\",,0)+1)

Code: Select all

; A_LineFile0.ahk :
Clipboard := A_LineFile . "`n"

; A_LineFile1.ahk
#Include,A_LineFile0.ahk
Clipboard .= A_LineFile . "`n"
MsgBox,% Clipboard
result =
(
....\A_LineFile0.ahk
....\A_LineFile1.ahk
)
Last edited by SL5 on 27 Feb 2018, 09:43, edited 1 time in total.
gregster
Posts: 3377
Joined: 30 Sep 2013, 06:48

Re: get name of include file

27 Feb 2018, 09:34

is this a new feature?
I guess this use for A_Linefile was added in 1.1.11.00 - June 21, 2013
User avatar
Delta Pythagorean
Posts: 485
Joined: 13 Feb 2017, 13:44
GitHub: DelPyth
Location: Somewhere in the US

Re: get name of include file

27 Feb 2018, 10:05

gregster wrote:
Delta Pythagorean wrote:A_LineFeed I think is what you're wanting.
There is A_LineFile, but no A_LineFeed.
Ack. Forgive me, I just woke up :crazy:
User avatar
jeeswg
Posts: 6904
Joined: 19 Dec 2016, 01:58
Location: UK

Re: get name of include file

27 Feb 2018, 10:09

A linefeed, `n.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA

Return to “Ask For Help”

Who is online

Users browsing this forum: ben95, grumegargler, joefiesta, MannyKSoSo, micchanahk, MikeyG12, toddhere, zvit and 115 guests