06-10-2016 12:43 PM - edited 06-10-2016 12:46 PM
Hello Guys,
What is the best way to use the command find for this situation.
For exemple.:
I have a variable and the value is AB1.
I need to show in another table all KEYS bellow who contains as Carac1, Carac2, Carac3 the value AB1
In this case the result should be:
M1
M3
M4
Note.: The table contains 1350 rows and 34 columns
Regrads.
Arthur
Solved! Go to Solution.
06-10-2016 01:13 PM
You could try something like the following to search each column of Table for all instances of AB1. Each time AB1 is found, the row # is added to a list if it's not already included.
var RowList : table[integer]
var i : integer
var j : integer
var nextRow : integer
RowList.create
for i := 1 to Table.XDim
j : = 1
while j <= Table.YDim
Table.setCursor(i,j)
if Table.find({i,j}..{i,Table.YDim},"AB1")
j := Table.cursorY
if not RowList.find({1,*},j)
nextRow += 1
RowList[1,nextRow] := j
end
else
j := TableYDim + 1
end
end
next
06-10-2016 02:17 PM
Ok! I got the idea, i will try it.
Let me ask you one more thing. The find works when the table cell contain more caracteres than the word i'm looking?
For example trying to find "AB1" but my cell is "AB1 World" or "AB1Erth".
06-10-2016 02:47 PM
Then I don't believe find will work.
You'll need to examine the string within each cell. You can use the pos method for this. It will return 0 if the substring "AB1" is not found in the cell.
06-10-2016 02:57 PM
The first method you sent it's working.
Now i need to adapt the method to find " AB1 " between other carachteres. I don't know how to use the pos method, i never used before.
06-10-2016 03:41 PM
FOR local J := 1 to .Models.Frame.table.XDIM loop for local i := 1 to .Models.Frame.table.ydim loop V:= pos("AB1",.Models.Frame.table[J,I]); if v/= 0 then y:= .Models.Frame.tableR.ydim; .Models.Frame.tableR[1,y+1]:= .Models.Frame.table[2,i]; .Models.Frame.tableR[2,y+1]:= .Models.Frame.table[3,i]; .Models.Frame.tableR[3,y+1]:= "AB1"; end; next;
06-10-2016 03:52 PM
Looks like pos is being used correctly.
06-10-2016 04:13 PM