Sign in to follow this  
Followers 0
Newbie2

Using "Return" in a function

3 posts in this topic

Hi Guys,

I must be doing something very wrong...

$Expectedfilename="blabla"

If x () = 0 Then
    msgbox (0,"","no file")
Else
    msgbox (0,"","file exists")
EndIf

Func x ()
    $File=FileOpen ("c:\temp\file.txt", 0)
    
    While 1
        $FileName=FileReadLine ($File)
        If @error=-1 Then ExitLoop
        $Pos=StringInStr ($FileName, $ExpectedFileName)
        If $Pos<>0 Then
        ;Found the string
            $FileName=StringTrimLeft ($FileName,$Pos-1)
            FileClose ($File)
            Return "FileExists"
        EndIf
    WEnd
EndFunc

My x() func works, but I always get the same answer "No file", why?? the string do exists!! :idiot:

Share this post


Link to post
Share on other sites

#2 ·  Posted (edited)

You do Return "FileExists" when it finds the file.

Wel "FileExists" is a string which is numericly a 0.

Just change Return "FileExists" to Return 1

Edited by JdeB

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

10x, dude!

Edited by Newbie2

Share this post


Link to post
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
Sign in to follow this  
Followers 0