get name of include file

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
SL5
Posts: 879
Joined: 12 May 2015, 02:10
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
Delta Pythagorean
Posts: 627
Joined: 13 Feb 2017, 13:44
Location: Somewhere in the US
Contact:

Re: get name of include file

27 Feb 2018, 08:44

A_LineFeed I think is what you're wanting.

[AHK]......: v2.0.12 | 64-bit
[OS].......: Windows 11 | 23H2 (OS Build: 22621.3296)
[GITHUB]...: github.com/DelPyth
[PAYPAL]...: paypal.me/DelPyth
[DISCORD]..: tophatcat

User avatar
jeeswg
Posts: 6902
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: 9002
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: 879
Joined: 12 May 2015, 02:10
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: 9002
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: 627
Joined: 13 Feb 2017, 13:44
Location: Somewhere in the US
Contact:

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:

[AHK]......: v2.0.12 | 64-bit
[OS].......: Windows 11 | 23H2 (OS Build: 22621.3296)
[GITHUB]...: github.com/DelPyth
[PAYPAL]...: paypal.me/DelPyth
[DISCORD]..: tophatcat

User avatar
jeeswg
Posts: 6902
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 (v1)”

Who is online

Users browsing this forum: RandomBoy and 245 guests