agreen Posted July 15, 2002 Posted July 15, 2002 Using FM 5.0, I have a found set of N records. Each record has a unique identifier field, and also a field containing the identifier of a companion record. I need to write a script which will create a found set of all of the original records plus the companion records. A seemingly reasonable way to do this would be to Enter Find Mode, and create a multi-record find extracting the ID numbers from the ID field plus the companion field. Thus for N records, the FIND would have 2N lines. However, once you enter Find mode, you can no longer "see" the original found set (you only see the find prototype fields). So it is necessary to capture all of the ID numbers before entering FIND mode. If N were small, it would be easy to set up a bunch of scratch global variables to temporarily store the ID values. But in my case, N can be quite large. I considered using a global repeated field, but there does not seem to be any way to access the repeating fileds one-by-one in a script. Any ideas how to do this?
RussBaker Posted July 15, 2002 Posted July 15, 2002 I'm assuming from your description that all the records are in the same file? If so, then create a text field called "Part of the last Find" and create a self relationship using Companion ID and Unique ID as the matching Key. As part of the find process, show all records and do a replace of Part of Last Find with "". Once you have your found set, do another Replace of Part of Last Find with "Yes". This marks all the records you have found with a "Yes". To mark all the companion records with a "Yes", Loop through the found set like this: Go to Record/Request [First] Loop SetField[Relationship::Part of Last Find,"Yes"] Go to Record/Request [Next][Exit After Last] End Loop Then, to find all the records (main and companion), add these script steps: Enter Find Mode [] Set Field[Part of Last Find,"Yes" Perform Find [] Then sort them however you want.
LiveOak Posted July 15, 2002 Posted July 15, 2002 Marking records works fine, unless you are in a multi-user environment with multiple people all trying to mark and find records, in which case all sorts of confusion will result. You can use a global text field with a relationship to the "unique identifier" field. Call this field gFound and the relationship RelFound 1) Find the set of records, go to a layout with a list view showing just the unique identifier field, no labels, no other fields, NOTHING ELSE! Script a "Copy All" and a Paste[select] (on another layout showing this field) to the gFound field. 2) Script a Set Field(gFound, gFound & "
agreen Posted July 15, 2002 Author Posted July 15, 2002 Russ and bd, thanks for your quick replies As bd divined, this will ultimately have multi-users. Also, the file is nearly 100,000 records long, so the reset and SetField passes would be long. bd, I have tried this and it works marvelously. I had not realized that GoToRelatedRecord could select more than one record.
LiveOak Posted July 15, 2002 Posted July 15, 2002 There is one limitation. The gFound global text field is limited to 64K characters. If your found set of identifiers (both types) has a lot of records with a 6 character (999,999 max) identifier and a <cr>, you will be limited to about 4,500 records in your found set. -bd
keshalyi Posted July 15, 2002 Posted July 15, 2002 Another way to do this, that allows the multiple users, is thus. Assuming each user has a unique user id of some sort, instead of having your mark field populate with just a mark, have it populate with the userid of the marker, and then a carriage return. You can make a relationship to this field, then, and you could have twenty different people with a mark in the field, and still relate to your one. Just make sure that you create a script that unmarks their username, and that clears all marks they've made when they close!
LiveOak Posted July 16, 2002 Posted July 16, 2002 You can do this. The problems are that it is slower than using a left side multi-key, there is always a way to exit without clearing marked records, and record locking may prevent a record from being marked and/or cleared. -bd
Recommended Posts
This topic is 8171 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 accountSign in
Already have an account? Sign in here.
Sign In Now