ReadIniFile default directory ?

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
Me_again
Automation Wizard
Posts: 1101
Joined: Fri Jan 07, 2005 5:55 pm
Location: Somewhere else on the planet

ReadIniFile default directory ?

Post by Me_again » Sun Nov 27, 2005 3:24 am

Does ReadiniFile look in a specific windows directory? Maybe I just confused myself, but it appears to me that IfFileExists> will look for the file in the current directory if there is no path specified, but ReadIniFile> doesn't default to the current directory.

So this code finds the .ini exists, but doesn't read it:

IfFileExists>myini.ini,start,nofile
Label>nofile
MessageModal>INI File Missing
Goto>theend
Label>start
MessageModal>this is start
ReadIniFile>myini.ini,data,outfile,outfile
.
.
.
Label>theend

If I hard code the path for the .ini it works fine. I'm compiling the macro and running it in its home directory in a cmd window.

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Sun Nov 27, 2005 8:36 am

Both take a file name so will work with the current directory and a full path.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Me_again
Automation Wizard
Posts: 1101
Joined: Fri Jan 07, 2005 5:55 pm
Location: Somewhere else on the planet

Post by Me_again » Mon Nov 28, 2005 6:02 am

mtettmar wrote:Both take a file name so will work with the current directory and a full path.
But that's not my experience, and I double checked on another PC today. If I compile this:

ReadIniFile>c:\ftps\myini.ini,settings,user,username
Let>msg=The Username is
ConCat>msg, %username%
MessageModal>msg

and copy it and the .ini to c:\ftps it works. If I change the ReadIniFile line to:

ReadIniFile>myini.ini,settings,user,username

compile and put it in the c:\ftps directory it doesn't find the .ini. I'm trying to create a compiled program that will work in any directory, what am I doing wrong?

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Mon Nov 28, 2005 6:28 am

How about using .\myini.ini ?

.\ should designate the current directory.
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Mon Nov 28, 2005 8:47 am

Me_again wrote:I'm trying to create a compiled program that will work in any directory, what am I doing wrong?
In that case use %SCRIPT_DIR% which is always set to the directory of the running script or executable:

ReadIniFile>%SCRIPT_DIR%\myini.ini,data,outfile,oufile
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Me_again
Automation Wizard
Posts: 1101
Joined: Fri Jan 07, 2005 5:55 pm
Location: Somewhere else on the planet

Post by Me_again » Mon Nov 28, 2005 2:20 pm

Both of those solutions work :D

Thank you gentlemen!

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts