Brian Dunning's FileMaker Custom Functions

FixedLength ( text ; char ; charsNumber ; align )

Returns a fixed length string.

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

Daniele Raybaudi   Daniele Raybaudi - Show more from this author
ACI
http://www.aci.it

Share on Facebook Share on Twitter

  Sample input:
FixedLength ("aaa"; "0" ; 10 ; "Left" )

FixedLength ("aaa"; "0" ; 10 ; "Right" )
  Sample output:
aaa0000000

0000000aaa

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

FixedLength function

Author
Daniele Raybaudi

Format
FixedLength ( text ; char ; charsNumber ; align )

Parameters
text - any text or text field
char - any character (or string);
charsNumber - the fixed length of the resulting string
align - text that can assume the value of "Left" or "Right"; an empty string is the same of "Left"

Data type returned
text

Description
Returns a fixed length string.
For example, FixedLength ("aaa"; "0" ; 10 ; "Left" ) returns: aaa0000000;
FixedLength ("aaa"; "0" ; 10 ; "Right" ) returns: 0000000aaa.

 

Comments

JEJ   JEJ, Santa Rosa
Apr 9, 2018
Error in function, as "char" can't be used a parameter. Revised:

/*
FixedLength function

Author
Daniele Raybaudi

Format
FixedLength ( text ; singleChar ; charsNumber ; alignment )

Parameters
text - any text or text field
singleChar - any character (or string)
charsNumber - the fixed length of the resulting string
alignment - text that can assume the value of "Left" or "Right"; an empty string is the same of "Left"

Data type returned
text

Description
Returns a fixed length string

Examples
FixedLength ("aaa"; "0" ; 10 ; "Left" ) returns: aaa0000000
FixedLength ("aaa"; "0" ; 10 ; "Right" ) returns: 0000000aaa

April 7, 2006
Fixed jej 4-9-18
*/

Let(
string =
Case (
charsNumber > 0; singleChar & FixedLength ("" ; singleChar; charsNumber - 1 ; "");
""
);
Case(
alignment = "Left" or alignment = "";Left ( text & string ; charsNumber );
alignment = "Right"; Right ( string & text ; charsNumber);
string
)
)
 

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: