May 16, 200916 yr I am trying to write a script which will start at the first record of a found set and work progressively through all remaining records of that found set. While I have some idea of how to do this, I would like to know what script step I would need to write to compare a field from the previous record with the same field of the current record. If the contents of both fields are identical I want to perform a function, if they are not I want to perform a different function. It's how I write the comparison part of the script that I would like help with if possible. Edited May 16, 200916 yr by Guest
May 16, 200916 yr Hi maybe this one ( I did not try it ): Go to record [ first ] Loop Set variable[ $var ; Value: YourTable::YourField ] Go to record [ next ; exit after last ] If [ YourTable::YourField = $var ] perform a function Else perform a different function End If End Loop
May 17, 200916 yr Author Thanks for the reply. I will try it at work tomorrow. Can't quite remember off top of my head if Set Variable is an option in FM 6 though. If not is there an alternative to use?
May 17, 200916 yr Author Hi maybe this one ( I did not try it ): Go to record [ first ] Loop Set variable[ $var ; Value: YourTable::YourField ] Go to record [ next ; exit after last ] If [ YourTable::YourField = $var ] perform a function Else perform a different function End If End Loop Thanks for the reply Fenton, but what would the quoted script need to change to?
May 17, 200916 yr Try this script, where gValue is a global field: Go to Record/Request/Page [ First ] Set Field [ Table::gValue; Table::Field1 ] Loop Go to Record/Request/Page [ Next; Exit after last ] If [ Table::gValue=Table::Field1 ] #Do this... Else #Do that End If Set Field [ Table::gValue; Table::Field1 ] End Loop
May 18, 200916 yr Author With reference to the above regarding a global field. I may have a problem because the field I am wanting to compare common to both records is a related field. I guesss I could create another field and copy and paste the related field into the newly created field before the script moves to the next record. Then I could compare both fields in the current record and perform the relevant function. I was just hoping there was a less messy way than going down this route.
May 18, 200916 yr Huh? You are comparing a related field in one record to the same related field in another? Then just change the SetField step to look at the related field. However, you'll just see the first related record in each case. So it begs the question...why not do the compare in the child table? Please provide actual data samples and explanation. I think this is a case of providing you with a technique, without us knowing the context of your requirements.
Create an account or sign in to comment