gcue Posted December 31, 2008 Posted December 31, 2008 (edited) 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 December 31, 2008 by gcue
Valuater Posted December 31, 2008 Posted December 31, 2008 from help #include <file.au3> #include <array.au3> Dim $szDrive, $szDir, $szFName, $szExt $TestPath = _PathSplit(@ScriptFullPath, $szDrive, $szDir, $szFName, $szExt) _ArrayDisplay($TestPath,"Demo _PathSplit()") 8)
GEOSoft Posted December 31, 2008 Posted December 31, 2008 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!"
gcue Posted December 31, 2008 Author Posted December 31, 2008 ahh didnt know that function existed!! thanks.. =) from help #include <file.au3> #include <array.au3> Dim $szDrive, $szDir, $szFName, $szExt $TestPath = _PathSplit(@ScriptFullPath, $szDrive, $szDir, $szFName, $szExt) _ArrayDisplay($TestPath,"Demo _PathSplit()") 8)
gcue Posted December 31, 2008 Author Posted December 31, 2008 (edited) 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 December 31, 2008 by gcue
GEOSoft Posted December 31, 2008 Posted December 31, 2008 (edited) 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 & $dirIt 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 December 31, 2008 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!"
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now