legend Posted September 21, 2012 Posted September 21, 2012 is it possible to check if 2 files exists, and if 1 of them exists then do something, and if they both or just 1 of them exists, then do something?
jdelaney Posted September 21, 2012 Posted September 21, 2012 something like $bFileOne = FileExists ("file") $bFileTwo = FileExists ("file") If $bFileOne And $bFileTwo Then ; some action ElseIf $bFileOne And ( Not $bFileTwo ) Then ; some action ElseIf ( Not $bFileOne ) And $bFileTwo Then ; some action Else ; None of the files exist EndIf IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
legend Posted September 21, 2012 Author Posted September 21, 2012 (edited) thanks but is it possible to make it like: if any of those two files exists then do something Edited September 21, 2012 by legend
PhoenixXL Posted September 21, 2012 Posted September 21, 2012 $bFileOne = FileExists ("file") $bFileTwo = FileExists ("file") If $bFileOne And $bFileTwo Then ; Both Files Exist ;Now Do Something ElseIf $bFileOne And ( Not $bFileTwo ) Then ; File Two Doesnt Exist ; DO whatever you want ElseIf ( Not $bFileOne ) And $bFileTwo Then ; File One Doesnt Exist Else ; None of the files exist EndIf Your Question has already been answered BrewManNH 1 My code: PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners. MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.
AdmiralAlkex Posted September 21, 2012 Posted September 21, 2012 thanks but is it possible to make it like: if any of those two files exists then do somethingIf $bFileOne Or $bFileTwo .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface
Spiff59 Posted September 21, 2012 Posted September 21, 2012 (edited) Doing between 2 and 6 compares (3 compound If/Then statements) is not very efficient when only 2 compares are needed: $sResult1 = FileExists("C:test1.txt") $sResult2 = FileExists("C:test2.txt") If $sResult1 Then If $sResult2 Then ; do what I do when both 1 and 2 exist Else ; do what I do when only 1 exists EndIf Else If $sResult2 Then ; do what I do when only 2 exists Else ; do what i do when neither 1 or 2 exist EndIf EndIf ; a sneakier option $sResult = FileExists("C:test1.txt") $sResult += FileExists("C:test2.txt") * 2 Switch $sResult Case 0 ; do what i do when neither 1 or 2 exist Case 1 ; do what I do when only 1 exists Case 2 ; do what I do when only 2 exists Case 3 ; do what I do when both 1 and 2 exist EndSwitch typo Edited September 21, 2012 by Spiff59
kylomas Posted September 21, 2012 Posted September 21, 2012 @Spiff59, Nothing sneaky about making the tool work for you, good job! 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
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