ArviUTA Posted June 26, 2008 Share Posted June 26, 2008 Hi Guys, I have two arrays $array1 and $array2 which contains strings taken from seperate columns from excel sheets. I wasn't able to compare these strings. i used both StringCompare but they turned out to be negative even if the words are same. I even used StringStripWS to take away the white spaces . It was of no use, please give me some ideas. thanks Arvinth Link to comment Share on other sites More sharing options...
Developers Jos Posted June 26, 2008 Developers Share Posted June 26, 2008 Show some code/snippet how you are doing the compare and what the content of the arrays is. Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
ArviUTA Posted June 26, 2008 Author Share Posted June 26, 2008 Show some code/snippet how you are doing the compare and what the content of the arrays is. Jos ********************88getting values from excel in array *******************************************88 for $j = 1 To ($row - 1) $marry=_ExcelReadCell($oWorkbook,$j) _arrayinsert($array,$j-1,$marry) $array[$j-1] = StringTrimRight($array[$j-1], 1) Next ****************************8getting values for another array ******************************************* ### Since the column have interleaved spaces i have few extra conditions func arjun($obook) $r=3 while 1 $rowvar = _ExcelReadCell($obook,$r,4) ;MsgBox(0,"Values",$rowvar) if $rowvar = "" then $r+=1 ;MsgBox(0,"Values","i am here") $n+=1 if $n > 1 then ExitLoop EndIf Else ;MsgBox(0,"Values",$rowvar) ;MsgBox(0,"Vale of m",$m) _arrayinsert($array1,$m,$rowvar) $r+=1 $m+=1 ;ConsoleWrite($array1[$m]) $n=0 Endif WEnd for $k=0 to ($m) ConsoleWrite($array1[$k]) Next EndFunc **************************************************************************************************** ********************************** Both arrays have required information, but the array has the strings stored without any gap, whereas above one have one white space before and after the word i even used StringStripWS to strip the second array ie array1 just above this. but ultimately the space remain in array1. **************************************************************************************************** ********************************** ************** for matching ************************************************ for $j=0 to ($row-2) for $k=0 to $m if ($array[$j] == $array1[$k]) Then _ArrayAdd($array2,$array1[$k]) EndIf Next Next ******************************************************************************8 i may not be clear just replay me if you are not clear Link to comment Share on other sites More sharing options...
Developers Jos Posted June 26, 2008 Developers Share Posted June 26, 2008 Have you listed the exact content of both arrays to see what they contain and why there is no match ? SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
ArviUTA Posted June 26, 2008 Author Share Posted June 26, 2008 Have you listed the exact content of both arrays to see what they contain and why there is no match ?yes i console wrote them and for example if array1 contains an element "ssssssssss545454"array2 contains same element " sssssssssssss545454 " Link to comment Share on other sites More sharing options...
Developers Jos Posted June 26, 2008 Developers Share Posted June 26, 2008 Do you mean that the s'es are spaces? If so, you could strip all spaces when adding the cell content eg: _arrayinsert($array1,$m,StringStripWS($rowvar,3)) SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
ArviUTA Posted June 26, 2008 Author Share Posted June 26, 2008 Do you mean that the s'es are spaces? If so, you could strip all spaces when adding the cell content eg: _arrayinsert($array1,$m,StringStripWS($rowvar,3)) still no use Link to comment Share on other sites More sharing options...
aslani Posted June 26, 2008 Share Posted June 26, 2008 Based on the code you've provided, not sure if $m is GLOBAL or not, I think you should add; Return $m ...at the bottom of your function, else the matching loop will only loop once. [font="Georgia"]Chances are, I'm wrong.[/font]HotKey trouble?Stringregexp GuideAutoIT Current Version Link to comment Share on other sites More sharing options...
Developers Jos Posted June 27, 2008 Developers Share Posted June 27, 2008 still no useBuild and snippet that we can run containing some actual array values that do not work, else its difficult to help you as it will only be guessing.Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Malkey Posted June 27, 2008 Share Posted June 27, 2008 yes i console wrote them and for example if array1 contains an element "ssssssssss545454"array2 contains same element " sssssssssssss545454 "array1 contains an element...... "ssssssssss545454"array2 contains same element " sssssssssssss545454 "You mentioned array2 contains the same element. If you compare the above 2 strings they are not the same. Too many s's in array2. Link to comment Share on other sites More sharing options...
ArviUTA Posted July 10, 2008 Author Share Posted July 10, 2008 I Used StringSplit function to split the string and then inserted them again using _StringInsert function to get those blank spaces out. It was cumersome but it worked out thank you guys for your help Link to comment Share on other sites More sharing options...
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