Jump to content
Server Maintenance This Week. ×

Script Question


This topic is 5456 days old. Please don't post here. Open a new topic instead.

Recommended Posts

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 by Guest
Link to comment
Share on other sites

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

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This topic is 5456 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.