Jump to content

Typing "asd" in start of every line in .txt file


Recommended Posts

I'm feeling generous today...

#Include <File.au3>
#include <Array.au3>
Global $aLines, $sNewLines, $sPath = "./Test.txt"
If Not FileExists($sPath) Then FileWrite($sPath, "line1" & @CRLF & "Line2" & @CRLF & "line3")
_FileReadToArray($sPath, $aLines)
For $i = 1 to $aLines[0]
    $sNewLines &= "asd" & $aLines[$i] & @CRLF
Next
FileDelete($sPath)
Sleep(200)
FileWrite($sPath, $sNewLines)
Link to comment
Share on other sites

  • Moderators

I'm feeling generous today...

#Include <File.au3>
#include <Array.au3>
Global $aLines, $sNewLines, $sPath = "./Test.txt"
If Not FileExists($sPath) Then FileWrite($sPath, "line1" & @CRLF & "Line2" & @CRLF & "line3")
_FileReadToArray($sPath, $aLines)
For $i = 1 to $aLines[0]
    $sNewLines &= "asd" & $aLines[$i] & @CRLF
Next
FileDelete($sPath)
Sleep(200)
FileWrite($sPath, $sNewLines)oÝ÷ Ûú®¢×ßÙeër¢ìاÚ.±ä^LiÉëOjëh×6$s_string = "I am a line of text in a text file" & @CRLF & _
    "I am another line of text in a text file" & @CRLF & _
    "I am the last line of text in a text file"

$s_string = "asd" & $s_string
$s_new_string = StringRegExpReplace($s_string, "\n", "\1asd")
ConsoleWrite($s_new_string & @CRLF)
Edited by SmOke_N
damn code tags

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.

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