Jump to content

Write line to a file


Recommended Posts

Hello all,

i am stuck at jet another problem and it goes like this:

I have Serial.txt file with X number of lines in it. They are constantly adding into this .txt file.

Now i want to make a script that will read A line (the one i will select) and add a indicator to it like an X sign.

I hope my explanation of the problem was clear.

Read a line and add X to that line.

So far i haven't found anything about adding Strings to a line. All function i found in help file are adding string to the end of a file.

I allso tried with writing Serial.txt to serial2.txt with X to each line, that worked but i need a better solution.

Code i have so far:

#include <Array.au3>
#include <File.au3>


$File = "C:\Serials.txt"    
$file_temp =  "C:\Serials.2txt"
$file_open = FileOpen($File, 1)                         
$file_open_temp = FileOpen($file_temp, 1)
$st_line = 180                              
local $stevec = 1

while 1

    FileReadLine($File,$stevec)
    if @error = -1 then ExitLoop
    $stevec = $stevec+1

WEnd  


for $i = $st_line to $stevec-1

    $line = FileReadLine($File,$i)
    FileWriteLine($file_temp,$line & "      X")

Next

FileClose($file_open_temp)
FileClose($file_open)
Link to comment
Share on other sites

  • 1 year later...

Anyone can help me?....I want to make a script which can do the following:

in a .txt file I have some text (5 lines),how can I make the script to: If the 3 line is selected,then the script copy the 4 line!?

What do you mean with selected?

:alien: ~ Every Living Thing is a Code Snippet of World Application ~ :alien:

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...