Jump to content

Wont Open File If it Exists


Recommended Posts

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. =) :)

Link to comment
Share on other sites

  • Developers

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 etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • Developers

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 etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

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.

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