Brian Dunning's FileMaker Custom Functions

ClearRepeatingVariable ( variableName ; startIndex ; endIndex )

Clears a range of repetitions for a specified variable

  Average rating: 4.7 (29 votes) Log in to vote

Kevin Frank   Kevin Frank
Kevin Frank & Associates
http://www.kevinfrank.com

Share on Facebook Share on Twitter

  Sample input:
ClearRepeatingVariable ( "$$test" ; 1 ; 3 )
  Sample output:
None... but if $$test, $$test[2] and $$test[3] existed previously, they no longer will.

  Function definition: (Copy & paste into FileMaker's Edit Custom Function window)

I recently found myself needing to clear a whole bunch of repeating variables, and wrote this CF to make my life easier.

 

Comments

bob   bob
Dec 8, 2011
Again,

If I

ClearRepeatingVariable ( "$$test" ; 3 ; 1 )

that would only clear rep 3?
 
Kevin Frank   Kevin Frank, Arcata, CA
Dec 8, 2011
ClearRepeatingVariable ( "$$test" ; 3 ; 3 )
 
Howard Schlossberg   Howard Schlossberg, FM Professional Solutions
Aug 14, 2015
Thanks for this, Kevin. I tweaked it slightly to meet my current need, which is that I don't KNOW what my endIndex is. I DO know that there will never be blanks, so I added an option so that it will keep clearing repetitions until it gets to the first blank and it can then assume it is at the end. A simple change that may be helpful to someone...

/* Howard added: if endIndex = "end" then keep going until the FIRST blank repetition */


Let ( startIndex = Max ( 1 ; startIndex ) ;

Evaluate ( "Let ( " & variableName & "[" & startIndex & "] = \"\" ; \"\" )" ) &

Case (
endIndex < 0 and endIndex <> "end" ; "" ;
endIndex ≥ 0 and startIndex ≥ endIndex ; "" ;
endIndex = "end" and IsEmpty( Evaluate( variableName & "[" & startIndex+1 & "]" ) ) ; "" ;
ClearRepeatingVariable ( variableName ; startIndex + 1 ; endIndex )
)

)
 

Log in to post comments.

 

Note: these functions are not guaranteed or supported by BrianDunning.com. Please contact the individual developer with any questions or problems.

Support this website.

This library has been a free commmunity resource for FileMaker users and developers for 15 years. It receives no funding and has no advertisements. If it has helped you out, I'd really appreciate it if you could contribute whatever you think it's worth:

Under construction. Email me your wish list for improvements.