Sign in to follow this  
Followers 0
Skrip

File write to first line?

8 posts in this topic

how can you make autoit write to the first line of a file instead of the last one?


[left][sub]We're trapped in the belly of this horrible machine.[/sub][sup]And the machine is bleeding to death...[/sup][sup][/sup][/left]

Share this post


Link to post
Share on other sites



how can you make autoit write to the first line of a file instead of the last one?

_FileWriteLine()?

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

hi, the above codes actually forces the original first line to the second line and writes itself to the first line.

so how do i actually replace the first line? pls help. thanks.


mouse not found....scroll any mouse to continue.

Share this post


Link to post
Share on other sites

HI,

_FileWriteToLine has the option to overwrite or not.

So long,

Mega


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites

thanks th.meger,

well how do i add the codes so that by executing the script, it will actually perform the replacement of lines in all text files in a folder. i have heard ppl mentioning abt arrays...but i know nuts abt it.

kindkly assist pls.

thanks.


mouse not found....scroll any mouse to continue.

Share this post


Link to post
Share on other sites

thanks th.meger,

well how do i add the codes so that by executing the script, it will actually perform the replacement of lines in all text files in a folder. i have heard ppl mentioning abt arrays...but i know nuts abt it.

kindkly assist pls.

thanks.

You could use an array, but probably don't need to. There are two parts to what you want:

1. Iterate through a list of all .txt files in a folder

2. Overwrite the first line on each

For (1.): Start with FileFindFirstFile(), then use a While loop of FileFindNextFile() to get each .txt file

For (2.): Copy the files to a backup, then FileOpen() the backup for read and the original file for write. FileReadLine() for one line and FileWriteLine() once with your new first line. Another While loop (this one is nested inside the While loop for 1. above) the repeats FileReadLine()/FileWriteLine(), copying the rest of the backup file to the original.

Give a shot and post some code... you'll get more help, I'm sure!

Cheers!

:P


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

Share this post


Link to post
Share on other sites

Thanks PsaltyDS!

With your hints, guidance and encouragement, I am proud to say that I have managed to code the scripts!

:P


mouse not found....scroll any mouse to continue.

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