Brian Dunning's FileMaker Custom Functions

EliminatePrefix ( value ; prefix )

Recursively eliminate any prefixes

  Average rating: 4.1 (39 votes) Log in to vote

Martin Brunner   Martin Brunner
Zurich Financial Services
http://www.zurichconnect.ch

Share on Facebook Share on Twitter

  Sample input:
EliminiatePrefix (00000254058 ; 0 )
  Sample output:
254058

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

This function can be used, if it is not clear, how many times a certain prefix exists in front of a certain value. The function recursively eliminates the specified prefix.

 

Comments

comment   comment, VR
Aug 26, 2009
You can do the same thing with a simple, non-recursive calculation =

Let ( [
clean = Substitute ( text ; prefix ; "" ) ;
pos = Position ( text ; Left ( clean ; 1 ) ; 1 ; 1 )
] ;
Right ( text ; Length ( text ) - pos + 1 )
)
 
Hans   Hans, Munich
Aug 27, 2009
I am looking for the inverse function of this. Adding a prefix. The get from a number a text string with always the same lenght and "0" at the beginning. Who can help ?
(i.e.: input 123 -> output "000123")
 
comment   comment, VR
Aug 27, 2009
Try:

Right ( "00000" & input ; 5 )


Or:

SerialIncrement ( "000000" ; input )
 
Antonio Loera   Antonio Loera, Mexico
Jun 26, 2014
I try to use this explanation but i can get the output

My field name is Pn_Yoke
The Prefix is the letter P, sample P764-15543-001

The Output must be easy 764-15543-001, only I need the prefix P, the length of the
filed can be 15 characters or more
 
Antonio Loera   Antonio Loera, Mexico
Jun 26, 2014
I try to use this explanation but i can get the output

My field name is Pn_Yoke
The Prefix is the letter P, sample P764-15543-001

The Output must be easy 764-15543-001, only I need the prefix delete P, the length of the
filed can be 15 characters or more.

Could you please help me, I really need you support in this matter...
 
Martin   Martin
Jun 27, 2014
Antonio

That's a simple one:

Middle ( Pn_Yoke ; 2 ; 999)

Like this you start at the second character and take whatever comes behind. Hope that helps....
 
Antonio Loera   Antonio Loera, Mexico
Jun 27, 2014
Thanks a lot Martin Z.

Now I need validate the prefix P on the field, but I don't know how can get it,
By example the Data entry on the field is P764-15543-001 , I need validate the first character "P" prefix if the condition are met the ned step is use middle(Pn_Yoke ; 2 ; 999)
If the condition are not met we need delete the data entry on the field.

One more time thanks four you help on this matter..
 
Martin   Martin
Jun 30, 2014
Antonia

Again simple:

If ( Left ( Pn_Yoke ; 1 ) = "P" ; Middle(Pn_Yoke ; 2 ; 999) ; Pn_Yoke )

Regards,
Martin
 
Antonio loera   Antonio loera, Matehuala, Mexico
Jul 2, 2014
Thanks a lot Martin


I really apreciated you time and Support on this matter.

Sorry by my questions as beginner programming on file maker.


Now I need a condition when the prefix is different of "P" delete the information entry on the field, keept the mouse cursor on the same field until the prefix is equal to "P" and also send a message error like "Invalid Prefix".

Regards.
 
Leon   Leon, Albir Playa, Spain
Jul 17, 2014
Antonio,

In that case you're looking at a script, rather than just a Custom Function.

Create a script with the name: "Validate Pn_Yoke Field"
Enter the following in the script:

If [(not IsEmpty(db_Name::Pn_Yoke)) and (Upper(Left(db_Name::Pn_Yoke ; 1)) <> "P")]
Set Field [db_Name::Pn_Yoke ; ""]
Show Custom Dialog ["ERROR" ; "Invalid Prefix"]
Go to Field [db_Name::Pn_Yoke]
End If

Now go to the Pn_Yoke field on the layout and set up a script trigger for OnObjectExit. The trigger points to the Validate Pn_Yoke Field script.

That should do the trick. Good luck.

Regards,
Leon.
 

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