Author |
Message |
Lance Veitc #1 / 11
|
 Comparing fields in a two records
I have a file that has 170 fields in a record. I need to compare two records and take note of the fields that are different. Is there a way to loop through the fields to make this comparison without having to have a 170 line long IF statement. Could PROP:Field & PROP:Fields be manipulated in some way or other? TIA Regards, Lance
|
Mon, 21 Mar 2005 13:07:11 GMT |
|
 |
Kevin Erskin #2 / 11
|
 Comparing fields in a two records
Check out the FieldPairs Class In database oriented programs there are some fundamental operations that occur over and over again. Among these repetitive operations is the saving and restoring of field values, and comparing current field values against previous values. The ABC Library provides two classes (FieldPairsClass and BufferedPairsClass) that supply this basic buffer management. These classes are completely generic so that they may apply to any pairs of fields, regardless of the fields' origins.
Quote: > I have a file that has 170 fields in a record. > I need to compare two records and take note of the fields that are > different. > Is there a way to loop through the fields to make this comparison without > having to have a 170 line long IF statement. > Could PROP:Field & PROP:Fields be manipulated in some way or other? > TIA > Regards, > Lance
|
Mon, 21 Mar 2005 13:07:16 GMT |
|
 |
Lance Veitc #3 / 11
|
 Comparing fields in a two records
Thanks for the pointer. One problem is that I am using legacy in this app. Looks like one still has to declare the relation between the fields before it can be used. eg. Fields.AddPair(CUST:Name, CustQ.Name) !establish Name pair I might as well use the IF sav:field1 = actual:field1 then doSomeThing. I might be mistaken as I am not very familiar with ABC classes. Regards, Lance
Quote: > Check out the FieldPairs Class > In database oriented programs there are some fundamental operations that > occur over and over again. Among these repetitive operations is the saving > and restoring of field values, and comparing current field values against > previous values. > The ABC Library provides two classes (FieldPairsClass and > BufferedPairsClass) that supply this basic buffer management. These classes > are completely generic so that they may apply to any pairs of fields, > regardless of the fields' origins.
|
Mon, 21 Mar 2005 13:55:52 GMT |
|
 |
Nagli? Sloboda #4 / 11
|
 Comparing fields in a two records
Something like: Loop i# = 1 to 170 If WHOT(File1,i#) = WHOT(File2,i#) then message(WHO(File1,i#)&' = '&WHO(File2,i#),'Equal fields'). End Works ? Regards Slobodan
Quote: > I have a file that has 170 fields in a record. > I need to compare two records and take note of the fields that are > different. > Is there a way to loop through the fields to make this comparison without > having to have a 170 line long IF statement. > Could PROP:Field & PROP:Fields be manipulated in some way or other? > TIA > Regards, > Lance
|
Mon, 21 Mar 2005 13:54:41 GMT |
|
 |
Lance Veitc #5 / 11
|
 Comparing fields in a two records
Looks good - I will test it. Thanks Slobodan. Regards, Lance Quote: ----- Original Message -----
Newsgroups: comp.lang.clarion Sent: Thursday, October 03, 2002 3:54 PM Subject: Re: Comparing fields in a two records > Something like: > Loop i# = 1 to 170 > If WHOT(File1,i#) = WHOT(File2,i#) then message(WHO(File1,i#)&' = > '&WHO(File2,i#),'Equal fields'). > End > Works ? > Regards Slobodan
|
Mon, 21 Mar 2005 15:15:20 GMT |
|
 |
Steve Wilso #6 / 11
|
 Comparing fields in a two records
I think that should be Loop i# = 1 to 170 If WHAT(File1,i#) = WHAT(File2,i#) message(WHO(File1,i#)&' = '&WHO(File2,i#),'Equal fields') End End Best Regards, Steve W.
Quote: > Something like: > Loop i# = 1 to 170 > If WHOT(File1,i#) = WHOT(File2,i#) then message(WHO(File1,i#)& = > &WHO(File2,i#),'Equal fields'). > End > Works ? > Regards Slobodan
> > I have a file that has 170 fields in a record. > > I need to compare two records and take note of the fields that are > > different. > > Is there a way to loop through the fields to make this comparison without > > having to have a 170 line long IF statement. > > Could PROP:Field & PROP:Fields be manipulated in some way or other? > > TIA > > Regards, > > Lance
|
Tue, 22 Mar 2005 01:16:18 GMT |
|
 |
Ian Holdswort #7 / 11
|
 Comparing fields in a two records
Lance Checkout the Who Where & What commands. Cheers -- Ian Holdsworth Senior Programmer / Assistant IT Manager Response Analysis & Mailing Ltd --------------------------------------------------- Direct Line: +44 (0) 20 8880 8866 Switch Board: +44 (0) 20 8880 8140 Fax: +44 (0) 0870 134 0987
Web Site: www.ram-ltd.co.uk
Quote: > I have a file that has 170 fields in a record. > I need to compare two records and take note of the fields that are > different. > Is there a way to loop through the fields to make this comparison without > having to have a 170 line long IF statement. > Could PROP:Field & PROP:Fields be manipulated in some way or other? > TIA > Regards, > Lance
|
Tue, 22 Mar 2005 01:16:25 GMT |
|
 |
Lance Veitc #8 / 11
|
 Comparing fields in a two records
Thanks for the help to all of you. Instead of using the File Name, use the Record Structure name. FileOne FILE,DRIVER('Clarion'),PRE(f1) Record RECORD,PRE() field1 STRING(20) field2 STRING(20) Group1 GROUP gs1 STRING(20) gs2 STRING(20) END field3 STRING(20) END END fieldcontents1 ANY fieldcontents2 ANY OPEN(FileOne) get(FileOne,1) j# = FileOne{prop:fields} message('Fields='&j#) !returns 6 fields - Group is counted as a field Loop i# = 1 to j# fieldcontents1 &= WHAT(f1:record,i#) ! returns the field contents fieldcontents2 = WHO(f1:record,i#) ! returns the field name message('What: '& fieldcontents1 &'|Who: '& fieldcontents2 ) End Regards, Lance
|
Tue, 22 Mar 2005 01:16:51 GMT |
|
 |
Nagli? Sloboda #9 / 11
|
 Comparing fields in a two records
You ar right ! Keyboard mistake :-) Slobodan
Quote: > I think that should be > Loop i# = 1 to 170 > If WHAT(File1,i#) = WHAT(File2,i#) > message(WHO(File1,i#)&' = '&WHO(File2,i#),'Equal fields') > End > End > Best Regards, > Steve W.
> > Something like: > > Loop i# = 1 to 170 > > If WHOT(File1,i#) = WHOT(File2,i#) then message(WHO(File1,i#)& = > > &WHO(File2,i#),'Equal fields'). > > End > > Works ? > > Regards Slobodan
> > > I have a file that has 170 fields in a record. > > > I need to compare two records and take note of the fields that are > > > different. > > > Is there a way to loop through the fields to make this comparison > without > > > having to have a 170 line long IF statement. > > > Could PROP:Field & PROP:Fields be manipulated in some way or other? > > > TIA > > > Regards, > > > Lance
|
Tue, 22 Mar 2005 18:18:40 GMT |
|
|