allSystemsGo Posted March 1, 2013 Posted March 1, 2013 (edited) Maybe my logic is flawed...but I am having trouble coding a function sort of like this... IF aFunction() Then if FileExists("c:\path") Then if FileExists("c:\path1") Then;;; these If FileExists Then...are checking to see if files have been downloaded...there are about ten of these if FileExists("c:\path10") Then MsgBox(64,@ScriptName,"Downloads Complete!") Else MsgBox(64,@ScriptName,"Can't get them all!") EndFunc In that format it just gives me syntax errors...in this next format it always returns that the download did not complete, but it actually did... expandcollapse popupFunc gotTermServApps() If $Lmi=1 Then MsgBox(64,@ScriptName,"Got LogMeIn!") Else MsgBox(64,@ScriptName,"Could not get LogMeIn!") EndIf If $reader=True Then MsgBox(64,@ScriptName,"Got Reader!") Else MsgBox(64,@ScriptName,"Could not get Reader!") EndIf if $filezilla=True Then MsgBox(64,@ScriptName,"Got FileZilla!") Else MsgBox (64,@ScriptName,"Could not get FileZilla!") EndIf If $transact=True Then Msgbox(64,@ScriptName,"Got TransActPOS!") Else MsgBox(64,@ScriptName,"Could not get TransActPOS!") EndIf If $openManage=True Then MsgBox(64,@ScriptName,"Got OpenManage!") Else MsgBox(64,@ScriptName,"Could not get OpenManage!") EndIf IF $tp86=True Then MsgBox(64,@ScriptName,"Got ThinPrint Engine 8.6!") Else MsgBox(64,@ScriptName,"Could not get ThinPrint Engine 8.6!") EndIf If $tp90=True Then MsgBox(64,@ScriptName,"Got ThinPrint Engine 9.0!") Else MsgBox(64,@ScriptName,"Could not get ThinPrint Engine 9.0!") EndIf If $chrome=True Then MsgBox(64,@ScriptName,"Got Chrome!") Else MsgBox(64,@ScriptName,"Could not get Chrome!") EndIf EndFunc Although I do not really want a bunch of boxes popping up...just testing the logic really. Any help is appreciated! The $lmi, $reader, etc are all declared globally outside functions. This is the basic structure of the vars... global $lmi, $chrome, $filezilla, $mse32, $mse64, $reader, $tp86, $tp90, $tpClient, $transact $reader=FileExists(@DesktopDir & "\AdbeRdr11002_en_US.exe") Edited to be more decriptive... Edited March 1, 2013 by zsutton92
AoRaToS Posted March 1, 2013 Posted March 1, 2013 (edited) how about: Func something() $count = 0 If aFunction() Then if FileExists("c:\path") Then $count = $count + 1 EndIf if FileExists("c:\path1") Then;;; these If FileExists Then...are checking to see if files have been downloaded...there are about ten of these $count = $count + 1 EndIf if FileExists("c:\path10") Then $count = $count + 1 EndIf If $count = 10 Then MsgBox(64,@ScriptName,"Downloads Complete!") Else MsgBox(64,@ScriptName,"Can't get them all!") EndIf EndIf EndFunc Edited March 1, 2013 by AoRaToS s!mpL3 LAN Messenger Current version 2.9.9.1 [04/07/2019] s!mpL3 LAN Messenger.zip s!mpL3
Bowmore Posted March 1, 2013 Posted March 1, 2013 (edited) You are missing several EndIf It should be something like this $fSuccess = False IF aFunction() Then if FileExists("c:\path") Then if FileExists("c:\path1") Then;;; these If FileExists Then...are checking to see if files have been downloaded...there are about ten of these if FileExists("c:\path10") Then $fSuccess = True EndIf EndIf EndIf Endif if $fSuccess Then MsgBox(64,@ScriptName,"Downloads Complete!") Else MsgBox(64,@ScriptName,"Can't get them all!") EndIf Alternatively you could use this format $fSuccess = True IF aFunction() Then if Not FileExists("c:\path") Then $fSuccess = False if Not FileExists("c:\path1") Then $fSuccess = False if Not FileExists("c:\path10") Then $fSuccess = False Endif if $fSuccess Then MsgBox(64,@ScriptName,"Downloads Complete!") Else MsgBox(64,@ScriptName,"Can't get them all!") EndIf Edited March 1, 2013 by Bowmore "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook
AoRaToS Posted March 1, 2013 Posted March 1, 2013 Otherwise: Func something() If aFunction() Then if FileExists("c:\path") Then if FileExists("c:\path1") Then;;; these If FileExists Then...are checking to see if files have been downloaded...there are about ten of these if FileExists("c:\path10") Then MsgBox(64,@ScriptName,"Downloads Complete!") EndIf EndIf Else MsgBox(64,@ScriptName,"Can't get them all!") EndIf EndIf EndFunc s!mpL3 LAN Messenger Current version 2.9.9.1 [04/07/2019] s!mpL3 LAN Messenger.zip s!mpL3
allSystemsGo Posted March 1, 2013 Author Posted March 1, 2013 You are missing several EndIf It should be something like this $fSuccess = False IF aFunction() Then if FileExists("c:\path") Then if FileExists("c:\path1") Then;;; these If FileExists Then...are checking to see if files have been downloaded...there are about ten of these if FileExists("c:\path10") Then $fSuccess = True EndIf EndIf EndIf Endif if $fSuccess Then MsgBox(64,@ScriptName,"Downloads Complete!") Else MsgBox(64,@ScriptName,"Can't get them all!") EndIf You are correct, I did not include the EndIf in this write up of the code...but in my actual code, I did include the EndIf's, which resulted in error. I have since scrapped that code since it did not work..
AoRaToS Posted March 1, 2013 Posted March 1, 2013 You can also 'Return' if one of them isn't there to avoid going through all of them s!mpL3 LAN Messenger Current version 2.9.9.1 [04/07/2019] s!mpL3 LAN Messenger.zip s!mpL3
kylomas Posted March 1, 2013 Posted March 1, 2013 (edited) zsutton92, This will fix the syntax errors from the first posted code... If aFunction() Then If FileExists("c:\path") Then If FileExists("c:\path1") Then;;; these If FileExists Then...are checking to see if files have been downloaded...there are about ten of these If FileExists("c:\path10") Then MsgBox(64, @ScriptName, "Downloads Complete!") Else MsgBox(64, @ScriptName, "Can't get them all!") EndIf EndIf EndIf EndIf ; EndFunc <-------------- can't have thi without a func stmt A far as detecting whether or not downloads completed, if you are using inetget() then use inetgetinfo() in a loop to see if the download was successfull. kylomas edit: Holy shit, 4 posts within a minute, damn I'm slow!!! Edited March 1, 2013 by kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill
allSystemsGo Posted March 1, 2013 Author Posted March 1, 2013 how about: Func something() $count = 0 If aFunction() Then if FileExists("c:\path") Then $count = $count + 1 EndIf if FileExists("c:\path1") Then;;; these If FileExists Then...are checking to see if files have been downloaded...there are about ten of these $count = $count + 1 EndIf if FileExists("c:\path10") Then $count = $count + 1 EndIf If $count = 10 Then MsgBox(64,@ScriptName,"Downloads Complete!") Else MsgBox(64,@ScriptName,"Can't get them all!") EndIf EndIf EndFunc Hmm..thats an idea..I'll try that out.
allSystemsGo Posted March 1, 2013 Author Posted March 1, 2013 (edited) So this... expandcollapse popupFunc gotTermServApps() $count=0 If $Lmi= True Then $count=$count + 1 EndIf If $reader=True Then $count=$count + 1 EndIf if $filezilla=True Then $count=$count + 1 EndIf If $transact=True Then $count=$count + 1 EndIf If $openManage=True Then $count=$count + 1 EndIf IF $tp86=True Then $count=$count + 1 EndIf If $tp90=True Then $count=$count + 1 EndIf If $chrome=True Then $count=$count + 1 EndIf if $count=8 Then MsgBox(64,@ScriptName,"All Downloads Complete!") Else MsgBox(64,@ScriptName,"Can't get them all!") EndIf EndFunc Returns the MsgBox that says "Can't get them all!"...I am using a mixture of InetGet and FileCopy, but the actual checking procedure just checks if the file exists on the desktop...does it matter what method it used to get the file instead of just seeing if the file is there? Or are my If statements flawed? Edit...This method doesn't seem to work.. Edited March 1, 2013 by zsutton92
allSystemsGo Posted March 1, 2013 Author Posted March 1, 2013 You are missing several EndIf It should be something like this $fSuccess = False IF aFunction() Then if FileExists("c:\path") Then if FileExists("c:\path1") Then;;; these If FileExists Then...are checking to see if files have been downloaded...there are about ten of these if FileExists("c:\path10") Then $fSuccess = True EndIf EndIf EndIf Endif if $fSuccess Then MsgBox(64,@ScriptName,"Downloads Complete!") Else MsgBox(64,@ScriptName,"Can't get them all!") EndIf Alternatively you could use this format $fSuccess = True IF aFunction() Then if Not FileExists("c:\path") Then $fSuccess = False if Not FileExists("c:\path1") Then $fSuccess = False if Not FileExists("c:\path10") Then $fSuccess = False Endif if $fSuccess Then MsgBox(64,@ScriptName,"Downloads Complete!") Else MsgBox(64,@ScriptName,"Can't get them all!") EndIf So I want to use the opposite of what I am looking for? If the file exists, I want it to return false?
AoRaToS Posted March 1, 2013 Posted March 1, 2013 are you checking if the download finished? s!mpL3 LAN Messenger Current version 2.9.9.1 [04/07/2019] s!mpL3 LAN Messenger.zip s!mpL3
Bowmore Posted March 1, 2013 Posted March 1, 2013 So I want to use the opposite of what I am looking for? If the file exists, I want it to return false?Reversing the logic allows the code to be more compact. $fSucess is initially set to True if any of the files do not exist it is set to False.The end result is the same you have checked that all the downloaded files exist on the disk. "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook
kylomas Posted March 2, 2013 Posted March 2, 2013 !"...I am using a mixture of InetGet and FileCopyAre you downloading in the foreground or background?kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill
allSystemsGo Posted March 4, 2013 Author Posted March 4, 2013 Are you downloading in the foreground or background?kylomasI don't specify either one...I just use FileCopy.are you checking if the download finished?Just checking that the file is there.Reversing the logic allows the code to be more compact. $fSucess is initially set to True if any of the files do not exist it is set to False.The end result is the same you have checked that all the downloaded files exist on the disk.Oh..neat...I'll try that out.
allSystemsGo Posted March 4, 2013 Author Posted March 4, 2013 (edited) This returns the "Can't get them all!!" MsgBox after running....all applications are present on the desktop, Func gotApps() $fSuccess = False IF getApps() Then if $lmi Then if $reader Then if $filezilla Then if $transact then if $openManage then if $tp86 then if $tp90 then if $chrome then $fSuccess = True EndIf EndIf EndIf Endif EndIf EndIf EndIf EndIf EndIf if $fSuccess Then MsgBox(64,@ScriptName,"Downloads Complete!") Else MsgBox(64,@ScriptName,"Can't get them all!!") EndIf EndFunc I am wondering now, if it may be something do with the @DesktopDir path....does this path lead to the All Users Desktop, or the specific user at the time? Edited March 4, 2013 by zsutton92
Moderators JLogan3o13 Posted March 4, 2013 Moderators Posted March 4, 2013 Look in the helpfile for @DesktopDir, and you can answer that for yourself "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum!
allSystemsGo Posted March 4, 2013 Author Posted March 4, 2013 Look in the helpfile for @DesktopDir, and you can answer that for yourself It is for the current user..So I do not see why I keep getting the wrong message.
Moderators JLogan3o13 Posted March 4, 2013 Moderators Posted March 4, 2013 So why not simplify, and comment out all but one If Statement? Then work through them one at a time to see where you're having problems? "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum!
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