Jump to content
Sign in to follow this  

Last post reguarding topic: Included full sourecode to receive help

Recommended Posts

This program reads Database.txt, Copies main dir C:\TEST\Testpage\ to multiple different ones based on Split[1] and Split[3], So it created C:\TEST\Random1.1 , C:\TEST\Random2.2, Until 4.4

A file cap2.htm is found in C:\TEST\Testpage so it was copied to the Random.1-4 folders. The second loop reads file cap2.htm and goes to line 48 which contains "John Williams" , then replaces it with split[3] ( The information in the 3rd split which are 4 different names). Compile this program for your self, i included cap2.htm ..NOTE: FileWriteLine - Writes to the end of the file which is not what I need( I need to replace the text on line 48 that says John Williams with split[3], but when i MsgBox the output of $Worked it shows blank so there's also a problem with the way I programmed that, I cannot seem to fix this!!! Please help


1,John Williams,random1.jpg

2,Wilma Flinstone,random2.jpg

3,Andrew SandShrew,random3.jpg

4,Goma Patroni,random4.jpg

Do ; 
    If $LineRead="" Then ExitLoop
    DirCopy("C:\TEST\testpage\", "C:\TEST\"&$DirN[1]&"."&$Split[1])
Until $LineRead=""
    If $LineRead2="" Then ExitLoop
$Worked=StringReplace($ToBeReplaced,"John Williams",$Split[2])
Until $Lineread2=""
Edited by SmOke_N
Added code tags

Share this post

Link to post
Share on other sites

Your explanation of what you are trying to do is more confusing than your code itself, but you should comment your code on what you "think" its doing, because it looks like 1 big mess to me.

Also wrap it in Code tags so it looks easier to read.


On the replace part... this is all you would need I'd think:

If $aSplit[0] > 1 Then ;Notice some error checking to make sure I don't GPF
    $sFileRead = FileRead($sFile)
    $sFileRead = StringReplace($sFileRead, "John Williams", $aSplit[2])
    FileClose(FileOpen($sFile, 2));Erase Previous content of file
    FileWrite($sFile, $sFileRead)
    MsgBox(64, "File Content", $sFileRead);Of course you'd remove this.
    MsgBox(16, "Error", "Your code is about to blow up.")
Edited by SmOke_N

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.

Share this post

Link to post
Share on other sites

I have figured it out, I used _FileWriteToLine

made a new array for the name of the part of the line that was being replaced, it worked viola

took a lot of work :)

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...