Subscribe Bookmark RSS Feed

How to assign the value from a selected cell from one table into a selected cell of another table

breinoso

Community Trekker

Joined:

Apr 21, 2015

Hello:

I am trying to assign the value of a specific cell on a selected row from one table with the value from a cell of a selected row from a different table.

Below is the section of script. There is a third table used to get a group of serial numbers used for the lookup criteria (omitted for brevity).

I am able to successfully match 1 row from each of the tables (ateDataTable which is where I want the data FROM and correlationTable which is where I want to copy the data into).

____

For(k=1,k<=N Row(selectedRows),k++,

//Find the row in the ATE and Correlation tables that matches the serial number for the current row in the selected group of the bench table

debugSerialNumber=selectedRows:Serial Number[k];

selAteRows=ateDataTable << Select Where(:Part id == selectedRows:Serial Number[k],current selection("clear"));

numOfATERowsThatMatch = N Row( ateDataTable << Get Selected Rows );

selCorrRows=correlationTable << Select Where(:Serial Number == selectedRows:Serial Number[k],current selection("clear"));

numOfCorrRowsThatMatch = N Row( correlationTable << Get Selected Rows );

//Get the value of the ateNameToCompare for the current ATE table row that matched the Part ID. Assign it to the benchDataTable

debugValueCorrelATE = correlationTable:ATE;

debugValueATE = ateDataTable:ateNameToCompare;

if(numOfATERowsThatMatch>0,

correlationTable:ATE= ateDataTable:ateNameToCompare; //PROBLEM HERE!!!!

);

);

1 REPLY
pmroz

Super User

Joined:

Jun 23, 2011

Try this code.  Untested because I don't have your data, but the approach should work.  I'm using get rows where instead of select where.  Your biggest issue is that you're trying to set columns equal to each other.  Instead you need to supply the row number as an index.

For( k = 1, k <= N Row( selectedRows ), k++,

// Find the row in the ATE and Correlation tables that matches the serial number for the current row

// in the selected group of the bench table

      debugSerialNumber = selectedRows:Serial Number[k];

      selAteRows = ateDataTable << get rows Where(

            :Part id == selectedRows:Serial Number[k]);

      numOfATERowsThatMatch = N Row( selAteRows );

      m1 = 0;

      if (numOfATERowsThatMatch > 0,

            m1 = selaterows[1];

      );

      selCorrRows = correlationTable << get rows Where(

            :Serial Number == selectedRows:Serial Number[k]);

      numOfCorrRowsThatMatch = N Row( selCorrRows );

      m2 = 0;

      if (numOfCorrRowsThatMatch > 0,

            m2 = selCorrRows[1];

      );

// Get the value of the ateNameToCompare for the current ATE table row that matched the Part ID. Assign it to the benchDataTable

      If ( m1 & m2,

            correlationTable:ATE[m2] = ateDataTable:ateNameToCompare[m1];

      );

);