Con Posted October 5, 2007 Share Posted October 5, 2007 how do i create a txt file and then write and read off it?thanks in advance Hello? Link to comment Share on other sites More sharing options...
Valuater Posted October 5, 2007 Share Posted October 5, 2007 how do i create a txt file and then write and read off it?thanks in advanceFileOpen()FileWrite().. or _FileWriteLine()FileRead()... FileReadLine()FileClose()see help, there are many examples at the bottom of the page.... or you can take a class with Welcome to Autoit 1-2-3 in my signature below8) Link to comment Share on other sites More sharing options...
BrettF Posted October 5, 2007 Share Posted October 5, 2007 how do i create a txt file and then write and read off it? thanks in advance This should set you on your way: $file = FileOpen (@ScriptDir & "\test.txt", 9) FileWrite ($file, "THIS IS A LINE") FileClose ($file) $file = FileOpen (@ScriptDir & "\test.txt", 0) $msg = FileRead ($file) FileClose ($file) MsgBox (0, "File Contents", $msg) Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
Con Posted October 5, 2007 Author Share Posted October 5, 2007 This should set you on your way: $file = FileOpen (@ScriptDir & "\test.txt", 9) FileWrite ($file, "THIS IS A LINE") FileClose ($file) $file = FileOpen (@ScriptDir & "\test.txt", 0) $msg = FileRead ($file) FileClose ($file) MsgBox (0, "File Contents", $msg) y do u need the fileclose and then under it fileopen couldnt u just leave it open?? anyway thankyou for your help Hello? Link to comment Share on other sites More sharing options...
BrettF Posted October 5, 2007 Share Posted October 5, 2007 y do u need the fileclose and then under it fileopen couldnt u just leave it open??anyway thankyou for your helpThe reason it is opened 2 times is because it is opened in a different mode.A mode will control how the function operates for example these are the modes for FileOpen (): 0 = Read mode 1 = Write mode (append to end of file) 2 = Write mode (erase previous contents) 4 = Read raw mode 8 = Create directory structure if it doesn't exist (See Remarks). 16 = Force binary(byte) reading and writing mode with FileRead and FileWrite 32 = Use Unicode UTF16 Little Endian mode when writing text with FileWrite and FileWriteLine (default is ANSI) 64 = Use Unicode UTF16 Big Endian mode when writing text with FileWrite and FileWriteLine (default is ANSI) 128 = Use Unicode UTF8 when writing text with FileWrite and FileWriteLine (default is ANSI)You have to open it in a different mode to manipulate it. Way of the world as such... Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! 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