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.

Looping through all contents of Field X in a DB

Featured Replies

I'm a scripting newbie, so please bear with me. I've done a couple of looping scripts with numerical loop invariants, but don't know how to traverse the DB based on contents of a particular field.

Ex. Given database with two fields MANUFACTURER and COMPUTERTYPE, I want to loop through the DB once for each unique value of MANUFACTURER. How do I structure a Loop to do something like the following pseudocode:

for each MANUFACTURER

select (MANUFACTURER, COMPUTERTYPE);

<do other stuff I'll fill in here>

done

I'm a scripting newbie, other than really minor stuff...

Is this for a report? If so you can use sub-summaries to separate the Manufacturers.

If this is not for a simple sub-summary report, then something like this would allow you to do something at each unique manufacturer:

Go to Record/Request/Page [ First ]

Set Field [ gManufacturer , "" ]

Loop

If [ gManufacturer <> Manufacturer ]

# Next manufacturer found. Do something cool

Set Field [ gManufacturer , Manufacturer ]

End If

Go to Record/Request/Page [ Exit after last, Next ]

End Loop

gManufacturer is just a global that remembers the manufacturer that you were on.

If you are planning on running something like this often, or with large sets of data, then there are more efficient ways to do this.

  • Author

That makes sense, and I'll try it, but it is for a fairly large dataset.

Mind sharing that "more efficient" way?

Thanks!

P.S., No, a sub-summary report won't work for it.

Two possibilities come to mind:

A. Normalize the Manufacturer data into another file. Then you can easily loop through those. If needed, you can easily jump to the related Computer records to process records for a particular manufacturer.

B. Add two fields: Count of Records (summary, count of Record ID) and Count by Manufacturer (calculation, number result) = GetSummary(Count of Records, Manufacturer). And use a different global, gRecordNum.

Use a script like this to loop through:

Sort [ Restore ] //Sort by Manufacturer

Go to Record/Request/Page [ First ]

Set Field [ gRecordNum , 1 ] //Global for keeping track of the current record number

Loop

# Next manufacturer found. Do something cool

Set Field [ gRecordNum , gRecordNum + Count by Manufacturer ]

Exit Loop If [ gRecordNum great.gif Status(CurrentFoundCount) ]

Go to Record/Request/Page [ gRecordNum ]

End Loop

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.