Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

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

Recommended Posts

Posted

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

Posted

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.

Posted

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

This topic is 7432 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.