Sign in to follow this  
Followers 0
Con

How can i make a txt file

5 posts in this topic

how do i create a txt file and then write and read off it?

thanks in advance


Hello?

Share this post


Link to post
Share on other sites



how do i create a txt file and then write and read off it?

thanks in advance

FileOpen()

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 below

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

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)

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites

y do u need the fileclose and then under it fileopen couldnt u just leave it open??

anyway thankyou for your help

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

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  
Followers 0