October 9, 20214 yr Newbies Hello! I need help with a script with looping to evaluate and mark records. I have four fields: Name_Global, NameA, NameB and Tag. I want to have a result in a field: Tag that is true when either NameA or NameB is a match with Name_Global, but not when that same condition is in the following record(s). The first record does not need to be evaluated. Scenario: If the match is true for NameA, for example, in records 1 through 5, then no true result is needed. Records 6 through 10 is a match for NameB, so then record 6 Tag is true, but not records 7 to 10. Carrying on, records 11 through 15 is again a match with NameA so the Tag for record 11 is true, but not the remaining records 12 through 15. So, in other words, every time the match shows up in the OTHER field in the next record, then the tag is true. The first record that is a match in either NameA to NameB, gets a Tag a true, but not the following ones. I'm not sure if it matters or not, but please note that when a record is a match for, say, NameA, then NameB will have all kinds of other names that are not to be considered. The only name that needs to be used for evaluating is the one that is entered in Name_Global. If anyone could write a script for this, I would very much appreciate it. It seems my sense of logic is fading with age??? Edited October 9, 20214 yr by Calvin Tomm
October 9, 20214 yr I am having trouble following the logic you describe. It seems you want to mark the first record in a consecutive group of records that have a match (in either field?). If so, it should be possible to loop over the records and do something like: if a match is found and $match is false, mark the record and set $match to true; if no match is found, set $match to false; As an aside, it seems like there should be a simpler way to accomplish whatever this is supposed to accomplish - but you did not tell us anything about that.
October 9, 20214 yr Newbies If NameA or NameB matches Name_Global, set Tag to true and set a variable e.g. $LastMatch to Name_Global. Go to next record. If NameA or NameB matches $LastMatch go to previous record and set Tag to false, then return to next record. Clear $LastMatch then loop through the above steps until you get to the end of the set. Would that work? If you expect the majority of cases to be false you might want to do this the other way round, i.e. leave Tag as false and go back to it if you need to set it as true, to reduce the number of times you have to move between records. Not sure if it matters whether the match is with A or B, if it does you could have two variables, one storing the name and the other storing whether it was A or B.
October 9, 20214 yr I think using a real life, concrete example, even if you have to mock it up in Word or a Spreadsheet, and the desired result, may be more helpful (and quicker) to get you to a solution.
Create an account or sign in to comment