totoymola Posted October 11, 2005 Share Posted October 11, 2005 This is a working code, but I just want to know a different and better way of doing this. $F1 = 'MYPROGRAM1.EXE' $F2 = 'MYPROGRAM2.EXE' $F3 = 'MYPROGRAM3.EXE' $F4 = 'MYPROGRAM4.EXE' $F5 = 'MYPROGRAM5.EXE' If Not FileExists($F1) Then MsgBox(0, "ERROR", "The file " & $F1 & " is missing.") Exit EndIf If Not FileExists($F2) Then MsgBox(0, "ERROR", "The file " & $F2 & " is missing.") Exit EndIf If Not FileExists($F3) Then MsgBox(0, "ERROR", "The file " & $F3 & " is missing.") Exit EndIf If Not FileExists($F4) Then MsgBox(0, "ERROR", "The file " & $F4 & " is missing.") Exit EndIf If Not FileExists($F5) Then MsgBox(0, "ERROR", "The file " & $F5 & " is missing.") Exit EndIf Thanks. Link to comment Share on other sites More sharing options...
GaryFrost Posted October 11, 2005 Share Posted October 11, 2005 For $x = 1 To 5 If Not FileExists('MYPROGRAM' & $x & '.EXE') Then MsgBox(0, "ERROR", "The file " & 'MYPROGRAM' & $x & '.EXE' & " is missing.") Exit EndIf Next would be another way SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
/dev/null Posted October 11, 2005 Share Posted October 11, 2005 (edited) This is a working code, but I just want to know a different and better way of doing this.a generic way:dim $files[4] = ["file1.txt", "file2.txt","file3.txt","file4.txt"] for $i = 0 to Ubound($files)-1 if not FileExists($files[$i]) then msgbox(0,"","Missing file: " & $files[$i]) nextCheersKurt Edited October 11, 2005 by /dev/null __________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf * Link to comment Share on other sites More sharing options...
Valuater Posted October 11, 2005 Share Posted October 11, 2005 maybe this $F1 = 'MYPROGRAM1.EXE' $F2 = 'MYPROGRAM2.EXE' $F3 = 'MYPROGRAM3.EXE' $F4 = 'MYPROGRAM4.EXE' $F5 = 'MYPROGRAM5.EXE' $F_All = "" If Not FileExists($F1) Then $F_All = $F_All & $F1 & @CRLF EndIf If Not FileExists($F2) Then $F_All = $F_All & $F2 & @CRLF EndIf If Not FileExists($F3) Then $F_All = $F_All & $F3 & @CRLF EndIf If Not FileExists($F4) Then $F_All = $F_All & $F4 & @CRLF EndIf If Not FileExists($F5) Then $F_All = $F_All & $F5 & @CRLF EndIf If $F_All <> "" Then MsgBox(0, "Program Error", "The Following Program Files were Not Found. " & @CRLF & @CRLF & $F_All) hope that helps 8) Link to comment Share on other sites More sharing options...
bluebearr Posted October 11, 2005 Share Posted October 11, 2005 I modified so that the user is prompted with all the files that are missing, instead of only being told of the first missing file: $MyProgs = 'MYPROGRAM1.EXE|MYPROGRAM2.EXE|MYPROGRAM3.EXE|MYPROGRAM4.EXE|MYPROGRAM5.EXE' $MyProgsA = StringSplit( $MyProgs, "|") Dim $Missing = "" For $i = 1 to $MyProgsA[0] If Not FileExists($MyProgsA[$i]) Then $Missing = $Missing & $MyProgsA[$i] & ", " EndIf Next If $Missing <> "" Then $Missing = StringLeft($Missing, stringLen($Missing) -2) $NumSense = "file is " If StringInStr($Missing, ",") Then $NumSense = "files are " EndIf MsgBox(0, "ERROR", "The following " & $NumSense & "missing: " & $Missing) Exit EndIf BlueBearrOddly enough, this is what I do for fun. Link to comment Share on other sites More sharing options...
GaryFrost Posted October 11, 2005 Share Posted October 11, 2005 a generic way:dim $files[4] = ["file1.txt", "file2.txt","file3.txt","file4.txt"] for $i = 0 to Ubound($files)-1 if not FileExists($files[$i]) then msgbox(0,"","Missing file: " & $files[$i]) nextCheersKurt need beta for this one i believe SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
/dev/null Posted October 11, 2005 Share Posted October 11, 2005 need beta for this one i believeYep, you're right. Variable initialization does not work that way in the official release. But I'm so used to some nice features of the beta ... CheersKurt __________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf * Link to comment Share on other sites More sharing options...
totoymola Posted October 11, 2005 Author Share Posted October 11, 2005 Wow! Thanks a lot for all your replies. I will try all of them to see which one is more suitable for my need. Thanks again! 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