Jump to content

Don't Understand Return Values


Recommended Posts

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 by Buckw1
Link to comment
Share on other sites

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 by thatsgreat2345
Link to comment
Share on other sites

  • Moderators

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...