Mellon Posted July 2, 2008 Posted July 2, 2008 (edited) $NewChartclean="NO 2-2,no 1-1,no 2-3,no 1-2, no 5-6, no 8-1" $LengthOfChartString=StringLen($NewChartClean) If $LengthOfChartString > 10 Then;testing only should be at least 50 $WhereTobreak=StringInStr($NewChartclean,",",2,5); should return the position of the fifth comma $TeststringReplace=StringReplace($NewChartclean,$Wheretobreak,"<BR>") MsgBox(4096,"Test Of break",$TeststringReplace) EndifThe purpose of the sniplet is to find the fifth comma and replace it with the html line break. What I thought should be returned in $TeststringReplace was "NO 2-2,no 1-1,no 2-3,no 1-2, no 5-6 <BR> no 8-1". What is actually returned is "NO 2-2,no 1-1,no 2-3,no 1-2, no 5-6 <BR> 8-1" . Is this expected? Did I screw something up?edit:err, Topic should be "Expected behaviour and, if so, how do I work around it? Edited July 2, 2008 by Mellon
Airwolf Posted July 2, 2008 Posted July 2, 2008 $NewChartclean="NO 2-2,no 1-1,no 2-3,no 1-2, no 5-6, no 8-1" $LengthOfChartString=StringLen($NewChartClean) If $LengthOfChartString > 10 Then;testing only should be at least 50 $WhereTobreak=StringInStr($NewChartclean,",",2,5); should return the position of the fifth comma $TeststringReplace=StringReplace($NewChartclean,$Wheretobreak,"<BR>") MsgBox(4096,"Test Of break",$TeststringReplace) Endif The purpose of the sniplet is to find the fifth comma and replace it with the html line break. What I thought should be returned in $TeststringReplace was "NO 2-2,no 1-1,no 2-3,no 1-2, no 5-6 <BR> no 8-1". What is actually returned is "NO 2-2,no 1-1,no 2-3,no 1-2, no 5-6 <BR> 8-1" . Is this expected? Did I screw something up? edit: err, Topic should be "Expected behaviour and, if so, how do I work around it? Think of StringReplace as an Insert. It's replacing the 5th comma and the 3 characters after it with <BR>. Try this instead: $NewChartclean="NO 2-2,no 1-1,no 2-3,no 1-2, no 5-6, no 8-1" $LengthOfChartString=StringLen($NewChartClean) If $LengthOfChartString > 10 Then;testing only should be at least 50 $WhereTobreak=StringInStr($NewChartclean,",",2,5); should return the position of the fifth comma $TeststringReplace=StringLeft($NewChartclean,$Wheretobreak - 1) & "<BR>" & StringRight($NewChartClean,$LengthOfChartString - $Wheretobreak) MsgBox(4096,"Test Of break",$TeststringReplace) Endif Certifications: A+, Network+, Security+, Linux+, LPIC-1, MCSA | Languages: AutoIt, C, SQL, .NETBooks: AutoIt v3: Your Quick Guide - $7.99 - O'Reilly Media - September 2007-------->[u]AutoIt v3 Development - newbie to g33k[/u] - Coming Soon - Fate Publishing - Spring 2013UDF Libraries: SkypeCOM UDF Library | ADUC Computers OU Cleanup | Find PixelChecksumExamples: Skype COM Examples - Skype4COMLib Examples converted from VBS to AutoIt
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now