December 11, 201411 yr I have a situation where I have a table with 10 fields and only two records, and I want to compare them and spot any differences. I have written a script that compares the two records by: a) Set ten variables with the contents of the ten fields of record 1. Go to next record. c) Set ten more variables with the contents of the ten fields of record 2. d) Compare the twenty variables, a pair at a time (one from record 1, one from record 2) to be alerted when a pair doesn't match. But now I have to do the same thing to a table with 75 fields (and still just two records). I feel as if there may be a better way, as this would take a very long time to set up the way I was doing it. Does not seem efficient at all, and seems like it would easily break. Any input would be appreciated. Thank you.
December 11, 201411 yr If you want to spot the difference/s, then you must compare each pair individually. However, you could automate the process by having the script loop over the fields of the table/layout, using the FieldNames() function.
December 11, 201411 yr Author Thanks for your comment, Comment, You had a great idea. I've implemented that and works like a charm. Thank you! # Set Variable [$fields; Value:FieldNames ( Get ( FileName ) ; "Comparison Layout" )] Set Variable [$fieldCount; Value:ValueCount ( FieldNames ( Get ( FileName ) ; "Comparison Layout" ) )] Loop Set Variable [$currentField; Value:GetValue ( $fields ; $fieldCount )] Go to Records/request/Page [First] Set Variable [$value1; Value:GetField ($currentField)] Go to Records/request/Page [Next] Set Variable [$value2; Value:GetField ($currentField)] If [$value1 ≠ $value2] Show Custom Dialog ["Inequality"; "FieldName: " & $currentField & " doesn't match. Record 1: " & $value1 & " Record 2: " & $value2] End If Set Variable [$fieldCount; Value:$fieldCount - 1] Exit Loop If [$fieldCount = 0] End Loop
Create an account or sign in to comment