Jump to content
Sign in to follow this  

Auto it string concat for high number of strings

Recommended Posts


I have a problem in string  concatenation when strings are stored in a variable is very long. I have a 2 line text in notepad. no matter how long the text is; it will be on one line only. What i need is to add "<p>" at start of every text line and "</p>" at end of every text line: Eg of text:


First line:

align=center><IMG src="http://ricon.com/image/data/ricon_com.png"></p>

Second line

<EM><FONT face=Arial><FONT size=2><STRONG>Company Profile :</STRONG> </FONT></FONT></EM><EM><BR><FONT size=2 face=Arial>Hello! It's nice of you to take the time to get to know us better. </FONT></EM><EM><BR><FONT size=2 face=Arial>ricon.com founded by 2015 as ricon E-Commerce Pvt.Ltd. since then ricon serving thousands of customer all over india with quality products and services. We aims to provide you 'Quality Products at Local Prices' that's why every product we sale is chosen and shall be delivered to you with atmost love and affection. At 'ricon.com' we always strive to achieve the highest level of 'Customer Satisfaction' possible, we are quickly expanding our collaboration with the other leading brands in the market to give our customers wide range of products and the best online shopping experience. Do give us a chance to bring a smile on your face by serving you the product you desire :)<BR>Find the more attractive deals &amp; discounts, visit and follow us on <a href="www.ricon.com">www.ricon.com</a> | <a href="www.facebook.com/ricon">www.facebook.com/ricon</a></FONT>


Example of code written by me

Local , $mouse, $string, $stringadd

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#SciTEDir => C:\Program Files (x86)\AutoIt3\SciTE   UserDir => C:\Users\nik\AppData\Local\AutoIt v3\SciTE\AutoIt3Wrapper   SCITE_USERHOME => C:\Users\nik\AppData\Local\AutoIt v3\SciTE
#Region --- Au3Recorder generated code Start (v3.3.9.5 KeyboardLayout=00000409)  ---

#EndRegion --- Au3Recorder generated code Start (v3.3.9.5 KeyboardLayout=00000409)  ---
;tested and works
;it checks 2 strings from excel and ultraedit
;ultra edit cause excel find is pathetic

Local $Paused, $mouse, $string, $stringadd


AutoItSetOption('MouseCoordMode', 0)



For $n = 1 to 2 Step +1

    MouseClick('primary',239, 684,18,0)
    ;To bring scroll bar to start position in ultra edit


    MouseClick('primary',244, $mouse ,1,0)

    ;press shift and end button


    ;Retrieve the data stored in the clipboard.

    $stringadd = "<p>"&$string&"</p>"
    ;adds before and after html new line symnol

    ;inputs value added with html on clip ready for paste



    $mouse = $mouse + 17


This code replaces text file of first line successfully adding strings "<p>" and "</p>" at start and end of line.

but for Second line it does not replace and returns the line as it is. Can anyone please tell me why is it so? and how to solve this

Edited by nik_agrawal2000

Share this post

Link to post
Share on other sites

Hi, I see that this is your first post. Welcome to the AutoIt forum. I notice that you are using mouseclicks, copy and sends here, but there is a simpler and more effective way to do what you want. If the source is in a text file, you can use code something like this:

#include <file.au3>

$file = @DesktopDir & "\YourFileName.txt" ; assuming the file with two lines is on the desktop

$fileSize = _FileCountLines($file)
For $i = 1 to $fileSize Step 1
    $lineRead = FileReadLine($file, $i)
    FileWrite(@DesktopDir & "/NewFile.txt", "<p>" & $lineRead & "</p>" & @CRLF)

If this is not helpful, let us know more about what you are trying to accomplish.

RAID Calculator | Software Installer

The truth has been suppressed since the dawn of time.

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  

  • Create New...