Jump to content
Sign in to follow this  
ganon64

ignores completely whether a file exists

Recommended Posts

ganon64

it just ignores this completely and doesn't msg box or create the new file at all, it should extract variables from a txt document which it does but if this txt document doesn't exist i want it to create the txt document and quit the script so the user can enter the details into the txt document and restart the script.

If FileExists("adsettings.txt") = 0  Then
MsgBox(0, "Error", "adsettings.txt doesn't exist and has just been created, please add your details to it before running again.")
$file = FileOpen("adsettings.txt",2)
FileWriteLine($file,1) = "Directory"
FileWriteLine($file,2) = "Username 1"
FileWriteLine($file,3) = "Password 1"
FileClose($file)
Exit
EndIf
Dim $file = FileOpen("adsettings.txt",0)
Dim $ABBYY = FileReadLine($file,1)
Dim $username = FileReadLine($file,2)
Dim $pw = FileReadLine($file,3)
FileClose($file)

HotKeySet( "{F8}", "paused")
HotKeySet( "{F7}", "login")

while 1
    sleep(100)
WEnd

Func paused()
$status = "paused"
    while $status = "paused"
    sleep(100)
WEnd
EndFunc

Func login()
$status = "started"

Share this post


Link to post
Share on other sites
herewasplato

check the help file for the correct syntax on:

FileWriteLine($file, 1) = "Directory"

Edit: still looking at the If line....

Edited by herewasplato

[size="1"][font="Arial"].[u].[/u][/font][/size]

Share this post


Link to post
Share on other sites
danthe0

RE: The first post.

Shift your Dim lines to the top of your script and yeah, format of FileWriteLine should be changed to

FileWriteLine($file,"Directory") instead of FileWriteLine($file,1) = "Directory"

Share this post


Link to post
Share on other sites
herewasplato

try

If Not FileExists("adsettings.txt") Then

edit: If FileExists("adsettings.txt") = 0 Then

worked for me but only after I rewrote the line...

Edited by herewasplato

[size="1"][font="Arial"].[u].[/u][/font][/size]

Share this post


Link to post
Share on other sites
ganon64

thnx turns out i meant to use _FileWriteToLine instead actually not much difference but meh, anyway it still seems to not give me a msg box or anything or create the file like this, as if its ignoring the If FileExists line completely:

#include <File.au3>
Dim $file = FileOpen("adsettings.txt",0)
Dim $ABBYY = FileReadLine($file,1)
Dim $username = FileReadLine($file,2)
Dim $pw = FileReadLine($file,3)
If FileExists("adsettings.txt") = 0  Then
MsgBox(0, "Error", "adsettings.txt doesn't exist and has just been created, please add your details to it before running again.")
_FileCreate("adsettings.txt")
FileOpen("adsettings.txt",2)
_FileWriteToLine($file,1,"Directory",1)
_FileWriteToLine($file,2,"Username 1",1)
_FileWriteToLine($file,3,"Password 1",1)
FileClose($file)
Exit
EndIf
FileClose($file)

HotKeySet( "{F8}", "paused")
HotKeySet( "{F7}", "login")

while 1
    sleep(100)
WEnd

Func paused()
$status = "paused"
    while $status = "paused"
    sleep(100)
WEnd
EndFunc

Func login()
$status = "started"

Share this post


Link to post
Share on other sites
ganon64

nope wait was running some identical file script lol weird, it works just now i got weird other errors hehe here we go :)

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  

×