Jump to content
Sign in to follow this  
autocomplex

Wont Open File If it Exists

Recommended Posts

autocomplex

I am trying to check if the ReadMe file exists, and if it does, to open it. Else display that it could not be found. This is what I have tried using the Help File, but it doesn't seems to do either of the Open or say it doesn't exist. What am i Do wrong?

Case $msg = $MenuInstructions
            FileExists("ReadMe.txt")
            If NOT @Error Then
            FileOpen("ReadMe.txt",0)    
            Else
            SplashTextOn("Error:","File Not Found! You Must have deleted it!",200,300)
            EndIf

Any help is greatly appreciated. =) :)

Share this post


Link to post
Share on other sites
Jos

If FileExists("ReadMe.txt") Then
    FileOpen("ReadMe.txt", 0)
Else
    SplashTextOn("Error:", "File Not Found! You Must have deleted it!", 200, 300)
EndIf


SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     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
Misha

Problem was that @error was set earlier in the script, or what?

Share this post


Link to post
Share on other sites
Jos

Problem was that @error was set earlier in the script, or what?

FileExits() doesn't set the @error macro but just returns 1 if the file exists or 0 when not ...

:)


SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     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
Tiger

or this:

Case $msg = $MenuInstructions
            $var = FileExists("ReadMe.txt")
            If $var = 1 Then
            FileOpen("ReadMe.txt",0)   
            Else
            SplashTextOn("Error:","File Not Found! You Must have deleted it!",200,300)
            EndIf

My UDFs:- _RegEnumKey

Share this post


Link to post
Share on other sites
bogQ

still does nothing, it doesn't open the file at all ... nor does it show the splash text

FileOpen

--------------------------------------------------------------------------------

Opens a text file for reading or writing. things like array ....

$file = FileOpen("test.txt", 0)

; Check if file opened for reading OK
If $file = -1 Then
    MsgBox(0, "Error", "Unable to open file.")
    Exit
EndIf

FileClose($file)


; Another sample which automatically creates the directory structure
$file = FileOpen("test.txt", 10); which is similar to 2 + 8 (erase + create dir)

If $file = -1 Then
    MsgBox(0, "Error", "Unable to open file.")
    Exit
EndIf

FileClose($file)

I think that this is what you need...

ShellExecuteWait("ReadMe.txt")

ShellExecuteWait

--------------------------------------------------------------------------------

Runs an external program using the ShellExecute API and pauses script execution until it finishes.

...instead of FileOpen command or maby im wrong?

Edited by bogQ

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 

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  

×