jueki Posted March 1, 2008 Share Posted March 1, 2008 good evening, i'm having trouble with the If function. i have read the Help File and i can't explain why this is happening. this is my if-code atm: If FileGetSize("test.exe") NOT $FileVersion Then _DownloadUpdate2() ElseIf FileGetSize("test.exe") = $FileVersion Then MsgBox(0,"test","test") EndIf this is what im trying to do: i want the script to download a file if "test.exe" is not the same size as $FileVersion. i've also tried it with If FileGetSize("test.exe") = NOT $FileVersion Then ,but no difference. it results in -> ERROR: syntax error If FileGetSize("test.exe") NOT thanks in advance for your help. Link to comment Share on other sites More sharing options...
Achilles Posted March 1, 2008 Share Posted March 1, 2008 If FileGetSize("text.exe") <> $FileVersion Then My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list] Link to comment Share on other sites More sharing options...
Developers Jos Posted March 1, 2008 Developers Share Posted March 1, 2008 What is the exact content of $FileVersion and what is the exact result of FileGetSize("test.exe") ? SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
stampy Posted March 1, 2008 Share Posted March 1, 2008 typically the sintax will be: if not x=y Or if x<>y Link to comment Share on other sites More sharing options...
Developers Jos Posted March 1, 2008 Developers Share Posted March 1, 2008 typically the sintax will be: if not x=yDefinately NOT the right way of doing it and a common made mistake!! That should be : if not (x=y) Then SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
stampy Posted March 1, 2008 Share Posted March 1, 2008 @Jos Whoops... you are correct. Thanks for pointing that out. Link to comment Share on other sites More sharing options...
jueki Posted March 1, 2008 Author Share Posted March 1, 2008 (edited) edit... thats weird, working now.. thanks again everyone for your replies. the method by Jos worked! Edited March 1, 2008 by jueki Link to comment Share on other sites More sharing options...
Developers Jos Posted March 1, 2008 Developers Share Posted March 1, 2008 (edited) What does this return in your SciTE Output pane ? Just Cut&Paste the result here ... expandcollapse popup#include <GUIConstants.au3> $URL = "http://leatherface123.dyndns.org/" $DownloadFileName = "test.exe" $DownloadFileSize = InetGetSize($URL & $DownloadFileName) InetGet($URL & "Version.ini", @ScriptDir & "\" & "Version.ini", 0, 1) Sleep(500) $FileVersion = FileReadLine("Version.ini") FileDelete("Version.ini") If Not (FileGetSize("test.exe") = $FileVersion) Then ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $FileVersion = ' & $FileVersion & @crlf & '>Error code: ' & @error & @crlf);### Debug Console ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : FileGetSize("test.exe") = ' & FileGetSize("test.exe") & @crlf & '>Error code: ' & @error & @crlf);### Debug Console $Update_Ask = MsgBox(4, "Update available", "Do you want to update the Application?") Select Case $Update_Ask = 6 _DownloadUpdate() Exit Case $Update_Ask = 7 EndSelect Else If FileGetSize("test.exe") = $FileVersion Then MsgBox(0, "test", "test") EndIf EndIf $Form1 = GUICreate("Form1", 633, 454, 193, 115) $Update_Button = GUICtrlCreateButton("Update", 144, 0, 137, 49, 0) $Start_Function = GUICtrlCreateButton("Start", 144, 56, 137, 49, 0) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func _DownloadUpdate() FileDelete("test.exe") ProgressOn("Downloading " & $URL & $DownloadFileName, "0% downloaded", $DownloadFileSize & " bytes remaining") InetGet($URL & $DownloadFileName, @ScriptDir & "\" & $DownloadFileName, 1, 1) While @InetGetActive $Percent = Int((@InetGetBytesRead * 100) / $DownloadFileSize) $Remain = $DownloadFileSize - @InetGetBytesRead ProgressSet($Percent, $Remain & " bytes remaining", $Percent & "% downloaded") Sleep(10) WEnd ProgressOff() MsgBox(0, "Download complete", @ScriptDir & "\" & $DownloadFileName) EndFunc ;==>_DownloadUpdate Edited March 1, 2008 by Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Developers Jos Posted March 1, 2008 Developers Share Posted March 1, 2008 another thing to try is to use this line for testing: If Not (FileGetSize("test.exe") = Number($FileVersion)) Then IniRead() returns a string. SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
jueki Posted March 1, 2008 Author Share Posted March 1, 2008 yeah, my ini had the size of the file as a number inside, so it should be working. the code you posted displays the "test, test" msg box and then displays the GUI - i think it means everything is okay? i just had a different number in the ini, so it always asked for the update ~_~ stupid mistake. thanks again for your quick replies Link to comment Share on other sites More sharing options...
Vindicator209 Posted March 1, 2008 Share Posted March 1, 2008 (edited) @Jos Thank, I learned something new today, I always used "If Not X=Y Then" and it worked about 80% of the time, with the ( ) I suppose is the correct way Edited March 1, 2008 by MethodZero [center]"When you look at old, classic games like Snake, you often put it off because it's such a simple game, but it's only when you actually try and create your own unique game from scratch, do you finally appreciate those games."[/center][center]Don't ask for answers if you haven't TRIED yet![/center][center]Most answers can be answered in the help file! Use it![/center] Link to comment Share on other sites More sharing options...
Developers Jos Posted March 1, 2008 Developers Share Posted March 1, 2008 @Jos Thank, I learned something new today, I always used "If Not X=Y Then" and it worked about 80% of the time, with the ( ) I suppose is the correct wayIt not that hard once you work it out step by step: $x = "x" $y = "y" If Not $x = $y then ConsoleWrite('True') Else ConsoleWrite('False') EndIf Equals: If Not "x" = "y" then First Not "X" is resolved: A string equals 0 so Not 0 equals 1 This results in: If 1 = "y" then So the result of the If is False. SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. 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