Jump to content

Using "Return" in a function


Newbie2
 Share

Recommended Posts

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:

Link to comment
Share on other sites

  • Developers

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

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

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...