Jump to content

getting directory from INI entry


gcue
 Share

Recommended Posts

i have an INI entry that points to an INI file (which the user can chose):

[sETTINGS]

assets="c:\blah\blah\blah.ini"

i am trying to capture the directory where the INI resides, no matter now many subdirs its in or no matter the filename of the INI..

$adir = INIREAD($aINI, "SETTINGS", "assets", stringregexp(......)) ?

any ideas?

Edited by gcue
Link to comment
Share on other sites

i have an INI entry that points to an INI file (which the user can chose):

i am trying to capture the directory where the INI resides, no matter now many subdirs its in or no matter the filename of the INI..

$adir = INIREAD($aINI, "SETTINGS", "assets", stringregexp(......)) ?

any ideas?

$aDir = StringLeft($Ini, StringInStr($Ini, "\", 0, -1))

If it is from a line in the Ini file then it would be

$aDir = INIREAD($aINI, "SETTINGS", "assets", "")
$aDir = StringLeft($aDir, StringInStr($aDir, "\", 0, -1)

No need for a GegExp there. RegExps may be versatile but they are not fast.

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

interesting way of doing it..

do you think valuators way is cleaner?

this is what i got...

$apath=IniRead("u:\scripts\Dashboard\settings.ini", "settings", "assets_ini", "not_found")

$test = _PathSplit($apath, $drive, $dir, $fname, $ext)

$aDIR = $drive & $dir

$aDir = StringLeft($Ini, StringInStr($Ini, "\", 0, -1))

If it is from a line in the Ini file then it would be

$aDir = INIREAD($aINI, "SETTINGS", "assets", "")
$aDir = StringLeft($aDir, StringInStr($aDir, "\", 0, -1)

No need for a GegExp there. RegExps may be versatile but they are not fast.

Edited by gcue
Link to comment
Share on other sites

interesting way of doing it..

do you think valuators way is cleaner?

this is what i got...

$apath=IniRead("u:\scripts\Dashboard\settings.ini", "settings", "assets_ini", "not_found")

$test = _PathSplit($apath, $drive, $dir, $fname, $ext)

$aDIR = $drive & $dir

It all depends on what you need. I don't #include files if I can avoid it and in this case you appear to have a known path so I took the simple way. I don't see any reason for _PathSplit() in your question but others might. I also have a function to get the parent folder of a file or another folder but that was written primarily for USB sticks where the root could change so again it wasn't required here. Edited by GEOSoft

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...