Brian Dunning's FileMaker Custom Functions

NewWindowName ( name )

Generates a unique window name by appending -N to the window name.

  Average rating: 4.2 (23 votes) Log in to vote

Vaughan Bromfield   Vaughan Bromfield - Show more from this author

  Sample input:
NewWindowName ( "Untitled" )
  Sample output:
Untitled-2 if a window named Untitled is already open.

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

NewWindowName ( name )

by Vaughan Bromfield
Version 1.0
8 March 2012

Returns a unique window name based on the text passed to the function.

It attempts to use the same rules the FMP natively uses when duplicating windows:

If the window name already exists then " - n" is appended, where n≥2.

If the window name already has " - n" at the end then:
return the base window if it does not exist
else increment the number n.

 

Comments

unix   unix, Japan
Feb 1, 2016
You can use
SerialIncrement ( name ; 1 )
for incrementing right most number part in text.
 
Vaughan Bromfield   Vaughan Bromfield
Aug 10, 2025
This is not how the window naming in FMP works. If, say, we start with a window "Untitled" and spawn a new window from it, it will be "Untitled - 2". Spawn another window it will be "Untitled - 3". If the first "Untitled" window is closed and a new window is spawned, the new window will NOT be "Untitled - 4" it will be "Untitled" because the window naming algorithm goes back and "fills in" gaps before incrementing the window number suffix.

This custom function replicates the behaviour.
 
Vaughan Bromfield   Vaughan Bromfield
Aug 10, 2025
This is not how the window naming in FMP works. If, say, we start with a window "Untitled" and spawn a new window from it, it will be "Untitled - 2". Spawn another window it will be "Untitled - 3". If the first "Untitled" window is closed and a new window is spawned, the new window will NOT be "Untitled - 4" it will be "Untitled" because the window naming algorithm goes back and "fills in" gaps before incrementing the window number suffix.

This custom function replicates the behaviour.
 

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 21 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: