Lets say I compile a macro named SampleCM.exe and I place this SampleCM.exe is a any folder I want on my hard drive.
Then I place a text file with an unknown name into that folder.
What command should I include in the SampleCM.exe that would allow SampleCM.exe to search the folder that SampleCM.exe was placed into for the random textfile.
Here's my purpose.
The user will place the SampleCM.exe into any folder they wish. The variables that are used in SampleCM.exe are gathered from a textfile that is placed into the same folder that SampleCM.exe is placed.
I know I can use the following code to determine what the name of the .txt file is:
[code]
GetFileList>C:\folder\*.txt,files
Separate>files,C:\folder\,name
MDL>%name_2%
[/code]
But what command can I use to locate the folder that the user has put the actual macro and text file into?
locate directory and find file
Moderators: JRL, Dorian (MJT support)
The COMMAND_LINE variable tells you what drive:\path\file was executed. So one way to do this would be:
Code: Select all
Separate>%COMMAND_LINE%,\,path
sub>path_count,1
Let>k=1
Repeat>k
add>k,1
Let>var=path_%k%
Concat>path_1,\%var%
Until>k,path_count
\\Then to have the name surrounded by quotes
Concat>path_1,"
\\Or to have no quotes
StringReplace>path_1,",,path_1
Man, I hate to make you work more. I even looked at that in the help file but didn't think it was what I needed. I need to get a better understanding of the uses of the system variables.
[code]
COMMAND_LINE
Full command line string (path of running executable and parameters passed on the command line)
[/code]
Thank you, again!
In case anyone is interested; here is the full function:
[code]
//find exe to declare variables
Separate>%COMMAND_LINE%,\,path
sub>path_count,1
Let>k=1
Repeat>k
add>k,1
Let>var=path_%k%
Concat>path_1,\%var%
Until>k,path_count
//Take quotes away
StringReplace>path_1,",,path_1
//link path to .txt file
GetFileList>%path_1%\*.txt,files
Separate>files,%path_1%\,name
let>location=%path_1%\%name_2%
//display a message modal with the full path and .txt file name
MDL>%location%
[/code]
If there is more than one text file, a (;)semi-colon will appear at the end of the path. You may need to change the code above to seperate the semi-colon from the path\*.txt; if you expect there to be more than one text file.
[code]
COMMAND_LINE
Full command line string (path of running executable and parameters passed on the command line)
[/code]
Thank you, again!
In case anyone is interested; here is the full function:
[code]
//find exe to declare variables
Separate>%COMMAND_LINE%,\,path
sub>path_count,1
Let>k=1
Repeat>k
add>k,1
Let>var=path_%k%
Concat>path_1,\%var%
Until>k,path_count
//Take quotes away
StringReplace>path_1,",,path_1
//link path to .txt file
GetFileList>%path_1%\*.txt,files
Separate>files,%path_1%\,name
let>location=%path_1%\%name_2%
//display a message modal with the full path and .txt file name
MDL>%location%
[/code]
If there is more than one text file, a (;)semi-colon will appear at the end of the path. You may need to change the code above to seperate the semi-colon from the path\*.txt; if you expect there to be more than one text file.
Last edited by Snickers on Thu Sep 13, 2007 2:28 pm, edited 1 time in total.
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
While COMMAND_LINE can be used, the variable you are after is SCRIPT_DIR
From help:
"SCRIPT_DIR Directory of running script"
SCRIPT_DIR is "Location of Me". Whether "Me" is a compiled EXE or a .SCP file SCRIPT_DIR will return the folder that "Me" is in.
From help:
"SCRIPT_DIR Directory of running script"
SCRIPT_DIR is "Location of Me". Whether "Me" is a compiled EXE or a .SCP file SCRIPT_DIR will return the folder that "Me" is in.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
Oh, wow! That is insanely more simplistic.
From this:
[code]
//find exe to declare variables
Separate>%COMMAND_LINE%,\,path
sub>path_count,1
Let>k=1
Repeat>k
add>k,1
Let>var=path_%k%
Concat>path_1,\%var%
Until>k,path_count
//Take quotes away
StringReplace>path_1,",,path_1
//link path to .txt file
GetFileList>%path_1%\*.txt,files
Separate>files,%path_1%\,name
let>location=%path_1%\%name_2%
//display a message modal with the full path and .txt file name
MDL>%location%
[/code]
To this:
[code]
GetFileList>%SCRIPT_DIR%\*.txt,files
Separate>files,%SCRIPT_DIR%\,name
let>location=%SCRIPT_DIR%\%name_2%
[/code]
I love it!
If there is more than one text file, a (;)semi-colon will appear at the end of the path. You may need to change the code above to seperate the semi-colon from the path\*.txt; if you expect there to be more than one text file.
From this:
[code]
//find exe to declare variables
Separate>%COMMAND_LINE%,\,path
sub>path_count,1
Let>k=1
Repeat>k
add>k,1
Let>var=path_%k%
Concat>path_1,\%var%
Until>k,path_count
//Take quotes away
StringReplace>path_1,",,path_1
//link path to .txt file
GetFileList>%path_1%\*.txt,files
Separate>files,%path_1%\,name
let>location=%path_1%\%name_2%
//display a message modal with the full path and .txt file name
MDL>%location%
[/code]
To this:
[code]
GetFileList>%SCRIPT_DIR%\*.txt,files
Separate>files,%SCRIPT_DIR%\,name
let>location=%SCRIPT_DIR%\%name_2%
[/code]
I love it!
If there is more than one text file, a (;)semi-colon will appear at the end of the path. You may need to change the code above to seperate the semi-colon from the path\*.txt; if you expect there to be more than one text file.