Page 1 of 1
get name of include file
Posted: 27 Feb 2018, 07:52
by SL5
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
Re: get name of include file
Posted: 27 Feb 2018, 08:44
by Delta Pythagorean
A_LineFeed I think is what you're wanting.
Re: get name of include file
Posted: 27 Feb 2018, 08:49
by jeeswg
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
Re: get name of include file
Posted: 27 Feb 2018, 08:53
by gregster
Delta Pythagorean wrote:A_LineFeed I think is what you're wanting.
There is
A_LineFile, but no
A_LineFeed.
Re: get name of include file
Posted: 27 Feb 2018, 09:28
by SL5
A_LineFile
YES
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
)
Re: get name of include file
Posted: 27 Feb 2018, 09:34
by gregster
is this a new feature?
I guess this use for A_Linefile was added in 1.1.11.00 - June 21, 2013
Re: get name of include file
Posted: 27 Feb 2018, 10:05
by Delta Pythagorean
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
Re: get name of include file
Posted: 27 Feb 2018, 10:09
by jeeswg
A linefeed, `n.