Forum Discussion
There are all sorts of string operations you can use to pick apart the text with spaces
https://support.smartbear.com/testcomplete/docs/reference/program-objects/aqstring/methods.html
What I might do is read the whole text string from the UI into a variable, then use Trim to take the spaces out. After that you can loop through the string 2 spaces at a time and get the next pair out to compare to the database. Or you could not take the spaces out and loop through 3 at a time and do the compare with the first two and skip the space. Or if you don't mind destructive testing, you can compare to the first pair and then delete them so you are always comparing to the first two.
If you are certain the UI will display in format [text][space][text][space][text], you could consider using .split. Rough outline like so:
var UItext = holdcodesobject.contentText //This should be 'TB TR TT var UISplitText = UItext.split(' '); //Now compare one item at a time for(var I=0;i<UISplitText.length;i++) { //depending on usage, you should be able to use one of the following
/// OPTION 1 if(!databale.IsEOF()) {
databale.MoveNext() //or the method that moves to the next current record
if(UISplitText[i]!=datatable.GetValue(0)) //can't recall the syntax for getting the value from column 0 - you will need to double check this
{
log.error("a field didn't match");
break;
} } else { Log.Error("No data in datatable"); }
//OPTION 2
if(datatablerowcount>0)
{ if(UISplitText[I]!=[datatable row i, column 0] //consider aqstring.ToUpper() and .Trim() on both sides.
{
log.error("a field didn't match");
break; } }
}
else
{
Log.Error("No data in datatable");
}
Also, your first check could be to make sure that your UIsplitText's length is the same as the record count of your datatable before you even compare the items per row. If they aren't, there will obviously be an error in matching