GetNthRecordSet ( fieldName ; recordNumStart ; recordNumEnd )
Rate this function: Average rating: 3.9 (66 votes)
Discuss this Custom Function
Jonathan Mickelson, Thought Deveopment Corp.
Calculates a return delimited and sorted, values list from related, or local, field data.
|GetNthRecordSet ( Children::Name ; 1 ; "" ) == where 3 children's names exist, unsorted.
GetNthRecordSet ( FirstName ; 2 ; 4 ) == where 5 records in found set sorted by FirstName
--------------- CUSTOM FUNCTION DESCRIPTION BELOW ---------------------
Syntax: GetNthRecordSet ( fieldName ; recordNumStart ; recordNumEnd )
Warning: RECURSIVE FUNCTION
Description: Creates a return delimited value list of the values from the field specified,
beginning with the recordNumStart and ending with recordNumEnd. The
resultant value list' scope and sort are determined by the source field;
thus for local fields the sort is determined by the current sort of
records in the found set, for related fields it is by the relationship sort.
fieldName - Any local field, related field, or an expression that returns a field.
NOTE: For repeating fields this Custom function will only
see the first repetition, per record. Also, Globals will behave
similarly and the global will be display once for each record.
recordNumStart - The record number from which you want to begin getting data.
A null ("") or 0 value will set the start at the first record.
recordNumEnd - The record number after which you want to stop getting data.
A null ("") or 0 value will evaluate until the the last record based upon
the current field context, if the fieldname is local, it uses the FoundSet,
if the field is from a differnt context (ie. related field) it attaempts to use the
count of a related field that has a value, currently set to #, which is an
unstored calc of record number in every table (you can change this).
This parameter is inclusive, thus 10 will end the value list with the
10th record, including the contents of the field in that record, followed by
a return character.
Output Format: A return delimited text value list of the the contents of fieldName dictated
by the provided start and end record numbers, each value will be followed
by a return character.
Note: The result of GetNthRecordSet() will not be updated when the record
referred to by GetNthRecordSet() is a record other than the one in
which the calculation is currently being evaluated, ie. you may need to
refresh the value for related fields.
Examples: Given the following related Field data for Children::FirstNames, from record 1
of a table of parents:
Related Record 1 = Jimmy
Related Record 2 = Suzzie
Related Record 3 = Johnny
Related Record 4 = Dweezle
GetNthRecordSet ( Children::FirstNames ; "" ; "" ) = Jimmy¶Suzzie¶Johnny¶Dweezle¶
GetNthRecordSet ( Children::FirstNames ; 1 ; 3 ) = Jimmy¶Suzzie¶Johnny¶
GetNthRecordSet ( ParentFirstName ; "" ; "" ) = Value list of all parent names
in current found set, in sort order,
ending with the last record in the
current found set.
GetNthRecordSet ( ParentFirstName ; 30 ; "" ) = Value list beginning with the
30th parent name till the last
record in current found set,
in sort order.
Special Thanks: To Ray Cologon, for refining the IsValid test instead of a cumbersome
case test and his ubiquitously simplified code ideas!
To Erik Shagdar, for revising the function to improve it's speed and lighten
the memory impact in variable declarations, and for re-posting the improved version
for everyone to benefit from!
1.3 - 2018-07-02 ( Jonathan Mickelson ) Fixed two bugs:
(1) There was a bug in empty "recordNumEnd" declarations (though you could just require them) when calculating from a related record. It always used Get(FoundCount) for the endNumber even when evaluating a related child record. If user had a found set of 1 record locally, but was getting a related set of 3 records, it would only return the first related value.
Since the original calculation calls for empty 'recordNumEnd' parameters, the calc was improved to detect that the fieldName is from a different context than the current layout, and will attempt to get a count of the related values, via counting a known related field, in this case a field named # that is an unstored calc of Record Number, that exists in all tables of my solutions. (You could change this, or make it another field that you have, like a "__pkID" )
(2) There was a bug that due to FileMaker's way of counting Values, if the trailing return was left off, following a blank last value, FM wouldn't count the last blank value with Value Count.
Thus: "1¶2¶¶¶" where the 1st and 2nd related records had values and the 3rd and 4th didn't, would result in an erroneous Value Count = 3, rather than 4.
This was corrected by structuring the calc so that every value that gets returned will be followed by a return.
1.2 - 2018-06-14 ( Jonathan Mickelson ) Removed one additional call to GetNthRecord, storing and testing the result.
Restored some Case functions so the "else" can be omitted without defining "".
1.1 - 2017-12-05 ( Erik Shagdar ): 2x speed improvement - loop over the records ONCE instead of testing for validity,
then getting the value. added formatting. added documentation. converted case into if functions.
declare end var inside of the let to simply test below. use existing params instead of declaring
1.0 - 2006-03-02 ( Jonathan Mickelson ) original version.
Note: these functions are not guaranteed
or supported by BrianDunning.com. Please contact the individual
developer with any questions or problems.
This is my Custom Function and I want to
5 most recent comments | Show all 11 comments
Make a comment about this Custom Function (please try to keep it brief & to the point). Anyone can post:
Newest Custom Functions:
||ChiSquare3x2 ( param ; param ; param ; param )
||(Tue, Aug 14, 6:33am)
||ReverseByteOrder ( bytes )
||(Thu, Aug 09, 12:06pm)
||BytesToDec ( hex )
||(Thu, Aug 09, 11:47am)
||GetAsHexBytes ( number ; bytes )
||(Thu, Aug 09, 10:50am)
||ValCorrelationCoeff ( XValueList; YValueList; Xmean; Ymean; XStdDev; YStdDev )
||(Wed, Aug 08, 4:17pm)
||ValLeastSquaresSlope ( XValueList; YValueList; Xmean; Ymean )
||(Wed, Aug 08, 4:10pm)
||ValueMath ( List1 ; List2 ; operation )
||(Wed, Aug 08, 4:05pm)
||GetExtension ( File )
||(Tue, Aug 07, 10:22am)