blackmage999 Posted February 23, 2011 Share Posted February 23, 2011 (edited) #Include <File.au3>$PlayerName = ClipGet();;;;;open credit file or create newIf FileExists(@DesktopDir & "\PlayerCredits\" + $PlayerName & ".txt") Then $PlayerCreditFile = FileOpen(@DesktopDir & "\PlayerCredits\" + $PlayerName & ".txt", 0)Else _FileCreate(@DesktopDir & "\PlayerCredits\" + $PlayerName & ".txt") $PlayerCreditFile = FileOpen(@DesktopDir & "\PlayerCredits\" + $PlayerName & ".txt", 0)EndIf;;;;;get player credits$PlayerCredit = FileReadLine($PlayerCreditFile)FileClose($PlayerCreditFile)Im using this code in one of my scripts, but it fails to create a .txt. any help on what the problem might be would be appricatedEdit: I just relized i used +'s instead of &'s...fixed, but still fails to create my .txt Edited February 23, 2011 by blackmage999 Link to comment Share on other sites More sharing options...
Bowmore Posted February 23, 2011 Share Posted February 23, 2011 Try this. $PlayerCreditFile = FileOpen(@DesktopDir & "\PlayerCredits\" & $PlayerName & ".txt", 9) and read about the mode option for fileopen() in the help file "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook Link to comment Share on other sites More sharing options...
Varian Posted February 23, 2011 Share Posted February 23, 2011 Evidently _FileCreate cannot create a new directory. This works #include <File.au3> $PlayerName = ClipGet() ;;;;;open credit file or create new If FileExists(@DesktopDir & "\PlayerCredits\" & $PlayerName & ".txt") Then $PlayerCreditFile = FileOpen(@DesktopDir & "\PlayerCredits\" & $PlayerName & ".txt", 0) Else If Not FileExists(@DesktopDir & "\PlayerCredits") Then DirCreate(@DesktopDir & "\PlayerCredits") If Not _FileCreate(@DesktopDir & "\PlayerCredits\" & $PlayerName & ".txt") Then MsgBox(4096, @DesktopDir & "\PlayerCredits\" & $PlayerName & ".txt", " Error Creating/Resetting log. error:" & @error & @LF & @DesktopDir & "\PlayerCredits\" & $PlayerName & ".txt") Exit EndIf $PlayerCreditFile = FileOpen(@DesktopDir & "\PlayerCredits\" & $PlayerName & ".txt", 0) EndIf ;;;;;get player credits $PlayerCredit = FileReadLine($PlayerCreditFile) FileClose($PlayerCreditFile) Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now