 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
Tasman
Joined: 20 May 2006 Posts: 21
|
Posted: Sat May 20, 2006 7:41 pm Post subject: Get the Base name of the running script |
|
|
This is a very simple function that returns the base name (ie. the name of the script without the extention) for use by for instance ini scripts.
This way if the name of the main script or exe is changed a corresponding ini file can be created/used, avoiding errors.
Just in case anybody is wondering why I am posting small trivialities like this, it's that I am in the process of writing a minimalist shell based on AHK
and these are functions used in it and I thought they might come in handy by others.
I'll be posting more stuff in the next few days just do a search for Tasman (runbox replacement, volume replacement etc., things normally handled by explorer)
| Code: |
dbase := getscriptname() ; get the base name of this program without the extension
ini = %A_ScriptDir%\%dbase%.ini ; and create the name of, for instance an ini file to use with this script.
MsgBox, %ini%
getscriptname(){
dbase = %A_ScriptName%
Length := StrLen(A_ScriptName)-4
StringLeft, dbase, A_ScriptName, Length
return %dbase%
}
|
I have a working version of the shell running on my own computer but its not ready for the primelight yet. You need to be carefull with shells, if you mess up you might not be able to get windows running again.
A lot of testing remains before I post all of it. |
|
| Back to top |
|
 |
SKAN
Joined: 26 Dec 2005 Posts: 6264
|
Posted: Sat May 20, 2006 7:57 pm Post subject: Re: Get the Base name of the running script |
|
|
Dear Tasman,
| Tasman wrote: | This is a very simple function that returns the base name (ie. the name of the script without the extention) for use by for instance ini scripts.
This way if the name of the main script or exe is changed a corresponding ini file can be created/used, avoiding errors. |
Nice idea.. However it can be shortened to
| Code: | GetScriptName(){
StringTrimRight,Name, A_ScriptName, 4
Return Name
} |
... and I feel this is better version :
| Code: | GetScriptName(){
SplitPath, A_ScriptFullPath,,,,Name,
Return Name
} |
| Quote: | I'll be posting more stuff in the next few days just do a search for Tasman (runbox replacement, volume replacement etc., things normally handled by explorer)
I have a working version of the shell running on my own computer but its not ready for the primelight yet. You need to be carefull with shells, if you mess up you might not be able to get windows running again.
A lot of testing remains before I post all of it. |
Sounds interesting! .. Will await it.
Regards,  _________________
 |
|
| Back to top |
|
 |
Tasman
Joined: 20 May 2006 Posts: 21
|
Posted: Sat May 20, 2006 8:54 pm Post subject: |
|
|
Thanks for the tip Goyyah
Love it when I can do the same with less code.
Changed my other submission accordingly (a simple runbox). |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|