David91
5 years agoFrequent Contributor
Variable table findrow method
Please i need help with create variable table method findrow.. i found in TC community code:
def search_in_table(name):
table = Project.Variables.yourTableVar
table.Reset() counter = 1 #consider that first row contains column names while not table.isEOF(): counter += 1 if table.Value["Name"] == name: Log.Message(counter) table.Next()
I need to rewrite it in a jscript or javascript. I tried it but it made mistakes.. 😞
My rewrite code with bugs..
function search_in_table(name){
var table = KeywordTests.Cenotvorba.Variables.DOKL_SLEVA_1;
table.reset(); // error
var counter = 1;
while (!table.isEOF()) { // error
counter += 1
if (table.Value["Name"] == name) //error
{
Log.Message(counter)
table.Next()
}
}
}
Okay so I dont know what table.reset does I've never really used it. What I would do in your case is ( If you have your column number fixed which is not a great idea btw)
function FindDavid(){
table = Project.Variables.yourTableVar
for(var i=0; i<table.RowCount; i++){
var cell = table.cell(i,0) //whatever your column number is
if(cell.contentText == "David"){
return i;
}
}
}Try this and let me know.