Skip to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Script Question

Featured Replies

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

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

  • 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?

No script Variable in 6. You'll have to use a global field.

  • 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?

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

  • 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.

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

Important Information

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

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.