Cancel
Showing results for 
Search instead for 
Did you mean: 

Method to search by name

Pioneer
Pioneer

Hello

I have in my model situation where I want specify the parameters based on the name.

if @.Name="Part_Nr_1" then
	.Models.Frame.PartRatio := .Models.Frame.Order[6,1];

But that is useless when I change position in the table. How can I search by name?
Like, find current "name" in the table then  find other parameters.

schemat4.png

Regards

11 REPLIES

Re: Method to search by name

Legend
Legend

The easiest way is to activate ColumnIndex and RowIndex of your table. 

 

There we go : 

 

is 
do
 
print .Models.Frame.Order["PartRadio","Part_Nr_1"] ; -- 1.5 

end;

Re: Method to search by name

Pioneer
Pioneer

But if I want it to every parts, no only to Part_Nr_1? 
I thinking about somethink like:
find @.Name in Table Order then 
.Models.Frame.PartRatio := .Models.Frame.Order[...];

Re: Method to search by name

Legend
Legend
.Models.Frame.PartRatio := .Models.Frame.Order["PartRatio", @.Name] ; 

The index allows to get directly to the cell without a loop or a find method. 

 

 

Re: Method to search by name

Pioneer
Pioneer

I don't know why but it's not working.
it's ok when:

.Models.Frame.PartRatio := .Models.Frame.Order["PartRatio", 1 ];

but when:

.Models.Frame.PartRatio := .Models.Frame.Order["PartRatio", @.Name] ; 

PartRatio = 0 and @.Name = "Part_Nr_1"
schemat5.png

Re: Method to search by name

Legend
Legend
You sure you've activated the row index ?
Becarefull if there is a space "Part_Nr_1 " like this.

Attach the model then I can have a look !

Re: Method to search by name

Pioneer
Pioneer

Much about this I have problem.

Re: Method to search by name

Legend
Legend

Okay got it ! 

You cannot activate the Row Index for this table so you can use this the find method. 

 

Here we go ! 

 

is
do
	Order.CursorX := Order.GetColumnNo("Name"); -- starting position
	Order.CursorY := 1; -- set
	local index : integer := Order.find(@.Name) ; 
	
end;

index contains the number of the row you interested in ! 

Re: Method to search by name

Pioneer
Pioneer

I don't know what I'm doing wrong but it is still bug,  and in the code has nothing obut "PartRatio"?

Re: Method to search by name

Legend
Legend
is
do
	Order.CursorX := Order.GetColumnNo("Name"); -- starting position
	Order.CursorY := 1; -- set
	local index : integer := Order.find(@.Name) ; 
        .Models.Frame.PartRatio := .Models.Frame.Order["PartRatio", index ] ; 
	
end;