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

Name & Parameters: LastRepNumber ( repeatingField ; maxRepeat ) Description: Returns the number of the last not empty repetition, much like Last(repeatingField) returns its contents. Can be


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

Recommended Posts

Posted

Name & Parameters: [color:red][big] LastRepNumber ( repeatingField ; maxRepeat ) [/big]

Description: Returns the number of the last not empty repetition, much like Last(repeatingField) returns its contents.

Can be used with both 7 and 8 version of FileMaker, but is most useful with 8, where fields can be reached specifying the repetition number by a calculation.

For example, to set the next empty repetition to "whatYouWant" you can use:

Set Field [repeatingField [LastRepNumber ( repeatingField ; 10 ) +1];"whatYouWant"]

(where repeatingField has 10 rep).

This function comes in hand also if you want to clear all repetitions.

A simple loop:

Loop

Exit Loop if [LastRepNumber ( repeatingField ; 10 ) = ""]

Set Field [repeatingField [LastRepNumber ( repeatingField ; 10 )];""]

End Loop

Sample Input:

LastRepNumber ( repeatingField ; 10 )

Results:

returns a number between 1 and 10 ( or "" if repeatingField is empty )

Recursive: yes

Formula:

/*

LastRepNumber custom function



Author

Daniele Raybaudi



Type

Recursive



Format

LastRepNumber ( repeatingField ; maxRepeat )



Parameters

repeatingField - any repeating field, or an expression that returns a reference to a repeating field.

maxRepeat - the number of repetitions assigned to repeatingField



Data type returned

number



Description

Returns the number of the last not empty repetition, much like Last(repeatingField) returns its contents.

Can be used with both 7 and 8 version of FileMaker, but is most useful with 8, where fields can be reached specifying the repetition number by a calculation.

For example, to set the next empty repetition to "whatYouWant" you can use:



Set Field [repeatingField [LastRepNumber ( repeatingField ; 10 ) +1];"whatYouWant"]

(where repeatingField has 10 rep).



This function comes in hand also if you want to clear all repetitions.

A simple loop:



Loop

Exit Loop if [LastRepNumber ( repeatingField ; 10 ) = ""]

Set Field [repeatingField [LastRepNumber ( repeatingField ; 10 )];""]

End Loop



April 27, 2006



*/



Case (

IsEmpty ( Last ( repeatingField ) ) ; "" ;

Last ( repeatingField )  = GetRepetition ( repeatingField ; maxRepeat )  ; maxRepeat ; 

LastRepNumber ( repeatingField ; maxRepeat - 1)

) 

Required Functions:

Author(s):) raybaudi

Date: 04/27/06

Credits:

Disclaimer:

FM Forums does not endorse or warrantee these files are fit for any particular purpose. Do not post or distribute files without written approval from the copyright owner. All files are deemed public domain unless otherwise indictated. Please backup every file that you intend to modify.

LastRepNumber.zip

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