Demon777 Posted November 17, 2008 Share Posted November 17, 2008 Hello everyone. I got little prob here.I have an ini file. This ini file has following keys...:-------------------------[Files]FilePath1 = C:\Path\FileFileUrl1 = http://site/fileFilePath2 = C:\Path\FileFileUrl2 = http://site/fileFilePath3 = C:\Path\FileFileUrl3 = http://site/file:-------------------------So. My script should check if file exist under FilePath, if not then download this file from FileUrl.So this is what i have atm :Func _Check() $Filelist = @ScriptDir & "\Filelist.bin" $List = IniReadSection($Filelist, "Files") For $i = 1 To $List[0][0] If FileExists($List[$i][1]) Then Sleep(100) Else ;Get file from inet under fileurl. ;I have no idea how to get this url for right file. Endif Next EndFuncAfter it has checked all files it should exit. Thx. So is there any way to do it ? Link to comment Share on other sites More sharing options...
Demon777 Posted November 17, 2008 Author Share Posted November 17, 2008 No one ? =( Link to comment Share on other sites More sharing options...
Demon777 Posted November 17, 2008 Author Share Posted November 17, 2008 This is a new try... Func _Check() $Filelist = @ScriptDir & "\Filelist.bin" $List = IniReadSection($Filelist, "Files") $Number = 1 For $i = 1 To $List[0] Local $url = IniRead($Filelist, $List[$i], "Url" & $Number, "") Local $path = IniRead($Filelist, $List[$i], "File" & $Number, "") If Not FileExists($path) Then InetGet($url, $path) Else Sleep(10) EndIf $Number = $Number + 1 Next EndFunc Please help =/ Link to comment Share on other sites More sharing options...
PsaltyDS Posted November 17, 2008 Share Posted November 17, 2008 IniReadSection() returns a 2D array, so the first example was closer. But you are doing a FileExists() test on every key in the section, including the URLs. So maybe: Func _Check() $Filelist = @ScriptDir & "\Filelist.bin" $List = IniReadSection($Filelist, "Files") For $i = 1 To $List[0][0] If StringInStr($List[$i][0], "FilePath") Then If FileExists($List[$i][1]) Then Sleep(100) Else InetGet($List[$i + 1][1], $List[$i][1]) Endif EndIf Next EndFunc More error checking would be good, but that's the basic idea. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
Demon777 Posted November 17, 2008 Author Share Posted November 17, 2008 Still testing and it works perfect for now =) thx for example. If i found an error i will post ! Thx again! Link to comment Share on other sites More sharing options...
Demon777 Posted November 17, 2008 Author Share Posted November 17, 2008 (edited) Well i tryed this out. This function was for updating =) But i got 1 more prob. Code : Func _Update() Local $Filelist = @ScriptDir & "\Filelist.bin" Local $List = IniReadSection($Filelist, "Files") For $i = 1 To $List[0][0] If StringInStr($List[$i][0], "File") Then If Not FileExists($List[$i][1]) Then Sleep(100) InetGet($List[$i + 1][1], $List[$i][1]) If @error Then GUICtrlSetData($Label1, "Error while downloading ...") EndIf Else Return Endif ;Local $Size = FileGetSize($List[$i][1]) ;Local $OSize = InetGetSize($List[$i + 1][1]) If Not FileGetSize($List[$i][1]) = InetGetSize($List[$i + 1][1]) Then Sleep(100) InetGet($List[$i + 1][1], $List[$i][1]) If @error Then GUICtrlSetData($Label1, "Error while downloading ...") EndIf EndIf EndIf Next Return EndFunc When there are no files in folder, it downloads them and if files exist but has another size then it deletes old ones and downloads new ones. But it dont want to work. It downloading when files are not exist but its not updaiting when files have different size ... any ideas ? Edited November 17, 2008 by Demon777 Link to comment Share on other sites More sharing options...
Demon777 Posted November 17, 2008 Author Share Posted November 17, 2008 any help ? =/ Link to comment Share on other sites More sharing options...
PsaltyDS Posted November 17, 2008 Share Posted November 17, 2008 Well i tryed this out. This function was for updating =) But i got 1 more prob. Code : ; ...<snip> If Not FileGetSize($List[$i][1]) = InetGetSize($List[$i + 1][1]) Then ; ...<snip> When there are no files in folder, it downloads them and if files exist but has another size then it deletes old ones and downloads new ones. But it dont want to work. It downloading when files are not exist but its not updaiting when files have different size ... any ideas ? You have to carefully consider order of operations in a statement like that. The operator NOT is first before all others (see Operators section in help file). So you have the equivalent of this: If ( NOT FileGetSize($List[$i][1]) ) = InetGetSize($List[$i + 1][1]) Then You could group with parens: If NOT ( FileGetSize($List[$i][1]) = InetGetSize($List[$i + 1][1]) ) Then But it is much easier to use the correct <> operator: If FileGetSize($List[$i][1]) <> InetGetSize($List[$i + 1][1]) Then Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law 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