Jump to content

need help writing to .txt file


Recommended Posts

hi guys, Im trying to make a script through which you can write to a .txt file without opening it.

for example

$var = inputbox("???","???")

then i want to save $var into a .txt file on line 2 (for example), without actually opening the .txt file ofcourse. any ideas how i can do this?

Link to comment
Share on other sites

as far as I understand, you need the .txt file open for that. I want to write to the .txt file while its closed. or did i miss something ?

That doesn't make any sense, that's like asking how to access a safe without opening it.

Broken link? PM me and I'll send you the file!

Link to comment
Share on other sites

@OP:

Its impossible to write to a file without opening it. You do not have to use the file open function (_FileOpen()), just use FileWrite. It will open and close the handle as needed.

In Au3 HELP FILE,use fileopen and fileclose is needed.

I dunno why the help file tell us to do this,while AHK Fileappend needed in HELP FILE.

Link to comment
Share on other sites

In Au3 HELP FILE,use fileopen and fileclose is needed.

I dunno why the help file tell us to do this,while AHK Fileappend needed in HELP FILE.

When you open the file with FileOpen() first, it gives you more options, that's all. If you pass a string path to FileWrite(), you will get the default behavior of appending in ANSI format (with an exception that binary data will be appended in binary "byte by byte"). If you want anything other than that default behavior, you need to use FileOpen() first to define your preference and pass the handle to FileWrite().

The _FileWriteToLine() function does not accept a handle, because it needs control over the mode as it switches between reading and writing to the file.

Perhaps the help file could be clearer on that point, but the behavior is logical and consistent.

:D

P.S. There is not now, nor will there ever be, any effort here to make AutoIt resemble AHK, so why bring that up?

:D

Edited by PsaltyDS
Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
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...