niteshade Posted June 6, 2009 Share Posted June 6, 2009 Trying to read a path from an INI file. However, I think it reads the value and places it in a string container-thingie i.e. between "", which doesn't let the rest of it work. I'll show you the code. expandcollapse popupGlobal $Backups = @WorkingDir & "\Backups" Global $Plugins = @WorkingDir & "\Plugins" Global $Temp = @WorkingDir & "\Temp" Global $Tools = @WorkingDir & "\Tools" ;READ PLUGIN DIRECTORY $AppName = IniRead($Plugins & "\MP3TAG.LB","Data","Name","App") $Path = IniRead($Plugins & "\MP3TAG.LB","Data","Path","LOL") MsgBox(0,"",$AppName) MsgBox(0,"",$Path) ToLocal($Path) $Date = GetDate() CompressFile($Date,$AppName) Cleanup() MsgBox(0,"","Completed") ;FUNCTION - COPY TO LOCAL DIRECTORY Func ToLocal($Dir) FileDelete($Temp & "\*.*") DirCopy($Dir,$Temp,1) EndFunc ;FUNCTION - GET AND FORMAT DATE Func GetDate() $UnformattedDate = _DateTimeFormat( _NowCalc(),1) $FormattedDate = StringReplace($UnformattedDate," ","-") Return $FormattedDate EndFunc ;FUNCTION - COMPRESS FILE Func CompressFile($FDate,$APP) Run(@ComSpec & " /c " & "7z.exe a -y " & $Backups & "\" & $APP & "_" & $FDate & ".7z " & $Temp & "\*", $Tools, @SW_HIDE) EndFunc ;FUNCTION - CLEAR TEMP DIRECTORY Func Cleanup() DirRemove($Temp & "\",1) DirCreate($Temp) EndFunc The contents of the INI file are as follows: [Data] Name = MP3Tag Path = @UserProfileDir & "\AppData\Roaming\Mp3tag" Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted June 6, 2009 Moderators Share Posted June 6, 2009 You're using a macro in the return string. You kind of need to define it first. See if this helps: $Path = '"' & _ConvertMacroFromString(IniRead($Plugins & "\MP3TAG.LB","Data","Path","LOL")) & '"' Func _ConvertMacroFromString($s_str); Cheap version, think I wrote an elaborate one once Local $a_macros = StringRegExp($s_str, "(\@\w+)", 3) If @error Then Return SetError(1, 0, $s_str) Local $s_macro, $s_escape = "(\.|\||\*|\?|\+|\(|\)|\{|\}|\[|\]|\^|\$|\\)" For $i = 0 To UBound($a_macros) - 1 $s_macro = Execute($a_macros[$i]) If @error Or $s_macro = "" Then ContinueLoop $s_macro = StringRegExpReplace($s_macro, $s_escape, "\\$1") $s_str = StringRegExpReplace($s_str, _ "(\A|\W)(" & $a_macros[$i] & ")(\W|\z)", _ "$1" & $s_macro & "$3") Next Return $s_str EndFunc Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted June 6, 2009 Moderators Share Posted June 6, 2009 Knew I had done something else like this:http://www.autoitscript.com/forum/index.ph...st&p=528667 Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
niteshade Posted June 9, 2009 Author Share Posted June 9, 2009 (edited) I've retried it, and changed some stuff in the INI file too. The path is returned correctly, but it still doesn't work expandcollapse popup#include <Array.au3> #include <Date.au3> #include <File.au3> #include <Constants.au3> Global $Backups = @WorkingDir & "\Backups" Global $Plugins = @WorkingDir & "\Plugins" Global $Temp = @WorkingDir & "\Temp" Global $Tools = @WorkingDir & "\Tools" ;READ PLUGIN DIRECTORY $AppName = IniRead($Plugins & "\MP3TAG.LB","Data","Name","App") $Path = '"' & _ConvertMacroFromString(IniRead($Plugins & "\MP3TAG.LB","Data","Path","LOL")) & '"' MsgBox(0,"",$AppName) MsgBox(0,"",$Path) ToLocal($Path) MsgBox(0,"","Copied") $Date = GetDate() CompressFile($Date,$AppName) Cleanup() MsgBox(0,"","Completed") MsgBox(0,"",RegRead("HKEY_LOCAL_MACHINE\Software\CCleaner","UpdateCheck")) ;FUNCTION - COPY TO LOCAL DIRECTORY Func ToLocal($Dir) FileDelete($Temp & "\*.*") DirCopy($Dir,$Temp,1) EndFunc ;FUNCTION - RETRIEVE REGISTRY KEYS Func RegRetrieve($REGPATH,$REGNAME) $REGVALUE = RegRead($REGPATH,$REGNAME) EndFunc ;FUNCTION - GET AND FORMAT DATE Func GetDate() $UnformattedDate = _DateTimeFormat( _NowCalc(),1) $FormattedDate = StringReplace($UnformattedDate," ","-") Return $FormattedDate EndFunc ;FUNCTION - COMPRESS FILE Func CompressFile($FDate,$APP) Run(@ComSpec & " /c " & "7z.exe a -y " & $Backups & "\" & $APP & "_" & $FDate & ".7z " & $Temp & "\*", $Tools, @SW_HIDE) EndFunc ;FUNCTION - CLEAR TEMP DIRECTORY Func Cleanup() DirRemove($Temp & "\",1) DirCreate($Temp) EndFunc Func _ConvertMacroFromString($s_str); Cheap version, think I wrote an elaborate one once Local $a_macros = StringRegExp($s_str, "(\@\w+)", 3) If @error Then Return SetError(1, 0, $s_str) Local $s_macro, $s_escape = "(\.|\||\*|\?|\+|\(|\)|\{|\}|\[|\]|\^|\$|\\)" For $i = 0 To UBound($a_macros) - 1 $s_macro = Execute($a_macros[$i]) If @error Or $s_macro = "" Then ContinueLoop $s_macro = StringRegExpReplace($s_macro, $s_escape, "\\$1") $s_str = StringRegExpReplace($s_str, _ "(\A|\W)(" & $a_macros[$i] & ")(\W|\z)", _ "$1" & $s_macro & "$3") Next Return $s_str EndFunc Here's the INI file: [Data] Name = MP3Tag Path = @UserProfileDir\AppData\Roaming\Mp3tag Edited June 9, 2009 by niteshade Link to comment Share on other sites More sharing options...
Juvigy Posted June 9, 2009 Share Posted June 9, 2009 So why dont you use only "\AppData\Roaming\Mp3tag" from the ini file and then concatenate @UserProfileDir in autoit like $realpath=@UserProfileDir&path Link to comment Share on other sites More sharing options...
niteshade Posted June 10, 2009 Author Share Posted June 10, 2009 Thanks ... should have done that earlier. Knew I was being stupid somewhere along the lines. Link to comment Share on other sites More sharing options...
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