AutoHotkey Community

It is currently May 26th, 2012, 6:17 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: A_IncludeScriptName
PostPosted: February 16th, 2005, 5:58 am 
---C:\Autohotkey\Autohotkey.ini
Code:
Gosub, test
#Include Script\test.ahk


---- C:\Autohotkey\Script\test.ahk
Code:
test:
msgbox, scriptName=%A_ScriptDir%\%A_ScriptName%
return


Code:
result
  scriptName=C:\Autohotkey\Autohotkey.ini
I also want the method of acquiring the information on the Include script.
If it is possible to get to know one's Path (C:\Autohotkey\Script) and FileName (test.ahk) in test.ahk, it is in the same place as itself. It becomes easy to create test.ini.
Is it difficult to add these to Built-in Variables?

Moreover, it is still gladder if the Include state of a script can be known. It is because it becomes unnecessary to adopt the following ways of writing.

Code:
; delete a comment, if test2.ahk is Inculude.
; Gosub,Test2


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: February 16th, 2005, 9:36 am 
Offline

Joined: January 31st, 2005, 9:50 am
Posts: 3910
Location: Bremen, Germany
Is it this, what you want?

---C:\Autohotkey\Script\test.ahk

Code:
IncludeScript = Script\test.ahk
IfNotExist %A_SkriptDir%\%IncludeScript%
  ExitApp

Gosub, test
 
#Include %A_SkriptDir%\%IncludeScript%



---C:\Autohotkey\Autohotkey.ini
Code:
test:
msgbox, scriptName=%A_ScriptDir%\%IncludeScript%
return

_________________
Ciao
toralf
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 16th, 2005, 11:12 am 
Thank you for a reply. Your reply differed from that for which I was asking. When it was made, it thought that it was glad and tried.

---C:\Autohotkey\Autohotkey.ini

Code:
IncludeScript = Script\test.ahk
IfNotExist %A_ScriptDir%\%IncludeScript%
  ExitApp

Gosub, test
 
#Include %A_ScriptDir%\%IncludeScript%

---C:\Autohotkey\Script\test.ahk
Code:
test:
msgbox, scriptName=%A_ScriptDir%\%IncludeScript%
return


Error
#include file "%A_ScriptDir%\%IncludeScript%" cannot be opend.

(The file name and syntax error it was reverse errorless were corrected.)
while regrettable "#include" -- "%A_ScriptDir%" -- and -- It cannot use "%IncludeScript%".


To the next test.ahk was deleted and tried.

---C:\Autohotkey\Autohotkey.ini

Code:
IncludeScript = Script\test.ahk
IfNotExist %A_ScriptDir%\%IncludeScript%
  ExitApp

Gosub, test
 
#Include C:\Autohotkey\Script\test.ahk

Error
#include file "C:\Autohotkey\Script\test.ahk" cannot be opend.

Although it is regrettable "#include" It cannot skip dynamically, either.


Report this post
Top
  
Reply with quote  
 Post subject: Re: A_IncludeScriptName
PostPosted: February 16th, 2005, 3:13 pm 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
Guest wrote:
I also want the method of acquiring the information on the Include script. If it is possible to get to know one's Path (C:\Autohotkey\Script) and FileName (test.ahk) in test.ahk, it is in the same place as itself.

Is it difficult to add these to Built-in Variables?

Can you give a specific example of what this would be used for?

Does anyone think that #Include should be changed to allow switching directories? Example:
#Include C:\My Scripts ; Change working directory for #Include.
#Include StringRoutines.ahk

It could be used multiple times and would change the script's working directory for the purpose of #Include and maybe FileInstall commands, but probably not for the execution of the script (which would still use SetWorkingDir).


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 16th, 2005, 11:48 pm 
C:\Autohotkey\Autohotkey.ini
C:\Autohotkey\Script\hoge.ahk
C:\Autohotkey\Script\sub\sub1.ahk
C:\Autohotkey\Script\sub\sub2.ahk
C:\Autohotkey\Script\sub\sub3.ahk

--- C:\Autohotkey\Autohotkey.ini ---
Code:
autoexecute:
   Gosub,hoge_init
return
#include Script\hoge.ahk

--- C:\Autohotkey\Script\hoge.ahk ---
Code:
hoge_init:
   ;MyScript Setting file hoge.ini
   SplitPath,%A_ScriptFullPath%,OutFileName,OutDir,OutExtension,OutNameNoExt
   HogeInifile = %OutDir%\%OutNameNoExt%.ini
return
#include sub\sub1.ahk
#include sub\sub2.ahk
#include sub\sub3.ahk

#1::  Gosub,sub1  ;sub1.ahk
#2::  Gosub,sub2  ;sub2.ahk
#3::  Gosub,sub3  ;sub3.ahk

I want to carry out the packaging of the hoge.ahk and to Include it from a higher rank simply.
I do not want to be influenced of my home. I want the specification method which can be completed only by hoge.
Moreover, as for hoge.ahk, in addition, to operate, even if it performs alone is good.
Current directory which hoge.ahk uses at least for itself if it is impossible I want the structure the hoge.ahk itself is decided to be in the name of .ini.
Quote:
It could be used multiple times and would change the script's working directory for the purpose of #Include and maybe FileInstall commands, but probably not for the execution of the script (which would still use SetWorkingDir).


I am sorry. Since it is idle, how to use FileInstal is not known well. I do not consider compile of a script.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: February 16th, 2005, 11:54 pm 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
I don't yet see a significant benefit to discovering the directory from which an #Include file was loaded. It seems to me that you must know the directory to include it in the first place. Since you must know it, there is no large benefit to having a way to discover it.

#Include is intended to be a simple mechanism for including other files. For now, I think elaborate improvements to it would be seldom used, and thus a low priority.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 17th, 2005, 1:34 pm 
Isn't it so in demand? Although I thought that I was regrettable, I understood.
Thank you


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: June 16th, 2005, 7:27 pm 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
Finding out the file name of an include-file is now possible via A_LineFile. Also, #Include has been improved in v1.0.35.11 to be able to set a new working directory for subsequent uses of #Include and FileInstall (it can also resolve %A_ScriptDir%).

Thanks for the suggestions.


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: fragman, Yahoo [Bot] and 3 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group