Cancel
Showing results for 
Search instead for 
Did you mean: 

Find table

Pioneer
Pioneer

 

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

 


Capturar.JPG

 

In this case the result should be:

 

M1

M3

M4

 

Note.: The table contains 1350 rows and 34 columns

 

 

Regrads.

 

Arthur

7 REPLIES 7

Re: Find table

Legend
Legend

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

Re: Find table

Pioneer
Pioneer

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".  

Re: Find table

Legend
Legend

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.

Re: Find table

Pioneer
Pioneer

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.

 

Capturar.JPG

Re: Find table

Pioneer
Pioneer
		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;

Re: Find table

Legend
Legend

Looks like pos is being used correctly. 

Re: Find table

Pioneer
Pioneer
It is working now. Thank you for the suport. I never used the pos method before and now i know how to use.