Buckw1 Posted May 19, 2006 Share Posted May 19, 2006 (edited) Hi again, I have pretty much completed my little file search script but having one little problem. I'm using $eve_directory=("c:\program files\ccp\eve\") $text = "" $drive_letter = DriveGetDrive( "all" ) If NOT @error Then ToolTip("Found " & $drive_letter[0] & " drives",0,0) Sleep(2000) EndIf If FileExists($eve_directory & "eve.exe") Then tooltip ("Eve.exe found at "& $eve_directory,0,0) Sleep(2000) Else ToolTip($eve_directory & " eve.exe does not exist. Starting search function.",0,0) sleep(2000) ToolTip("Looking for eve.exe",0,0) sleep(2000) $i=2 Do $i=$i+1 $eve_directory=($drive_letter[$i] &"\ccp\eve\eve.exe") If Fileexists($eve_directory) then MsgBox(4096,"","Found Eve.exe at " & $eve_directory) EndIf Until $i=$drive_letter[0] If NOT Return then $eve_directory=inputBox("","Eve.exe NOT Found, Please enter the location.","c:\program files\ccp\eve\") EndIf EndIf I want to check the return value so I can ask the user to input the file location if not found. How? Buck Edited May 19, 2006 by Buckw1 Link to comment Share on other sites More sharing options...
Thatsgreat2345 Posted May 19, 2006 Share Posted May 19, 2006 (edited) heres a quick example if you do a return value then its going to return whatever you put after it where ever you put the function name so yeah, also check out like set error which works with @error i think $game_directory = "C:\" If _Check() = "IT EXISTS" Then MsgBox(0,"Game Exists","The Game " & $game_directory & " exists") Elseif _Check() = 0 Then;elseif just for example easier to do else MsgBox(0,"Doesn't","The Game Doesn't Exist") EndIf Func _Check() If FileExists($game_directory) Then Return "IT EXISTS" Else Return 0 EndIf EndFunc Edited May 19, 2006 by thatsgreat2345 Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted May 19, 2006 Moderators Share Posted May 19, 2006 heres a quick example if you do a return value then its going to return whatever you put after it where ever you put the function name so yeah, also check out like set error which works with @error i think $game_directory = "C:\" If _Check() = "IT EXISTS" Then MsgBox(0,"Game Exists","The Game " & $game_directory & " exists") Elseif _Check() = 0 Then;elseif just for example easier to do else MsgBox(0,"Doesn't","The Game Doesn't Exist") EndIf Func _Check() If FileExists($game_directory) Then Return "IT EXISTS" Else Return 0 EndIf EndFunc Checking a function twice there doesn't seem very efficient.$game_directory = "C:\" $Check_Value = _Check() If $Check_Value Then MsgBox(0,"Game Exists","The Game " & $game_directory & " exists" & @CR & 'And the Value Returned was: ' & $Check_Value) Elseif Not $Check_Value Then; I agree this should be an Else but you shouldn't need to check the function twice... MsgBox(0,"Doesn't","The Game Doesn't Exist" & @CR & 'And the Value Returned was: ' & $Check_Value) EndIf Func _Check() If FileExists($game_directory) Then Return 1 Else Return 0 EndIf EndFunc Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. 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