FixedLength ( )

Function stats

Average user rating
38
142
9999
Support
FileMaker 7.0 +
Date posted
15 December 2008
Version
1
Recursive function
Yes

Author Info
 Daniele Raybaudi

9 functions

Average Rating 5.0

author_avatar



 

Function overview

Prototype

FixedLength  ( text;   char;   charsNumber ;   align )


Parameters

text  the text that we have to adjust


char  the char that we want to use before or after the text


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"


Description

Tags:  format  

Returns a fixed length string.

For example:

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

FixedLength ("aaa"; "0" ; 10 ; "Right" ) returns: 0000000aaa.

Examples

Sample input

FixedLength ("aaa"; "0" ; 10 ; "Left" )


Sample output

aaa0000000

 

Function code

/*
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.

April 7, 2006
*/

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

// ===================================
/*

    This function is published on FileMaker Custom Functions
    to check for updates and provide feedback and bug reports
    please visit http://www.fmfunctions.com/fid/142

    Prototype: FixedLength( text; char; charsNumber ; align )
    Function Author: Daniele Raybaudi (http://www.fmfunctions.com/mid/38)
    Last updated: 15 December 2008
    Version: 1

*/
// ===================================

 

Comments

Fabrice
15 December 2008



Hi Daniele,
this one looks pretty much like a recursive version of : http://fmfunctions.com/fname/pad
doesn't it ? ;)
(Edited by Fabrice on 15/12/08 )
  General comment
Daniele Raybaudi
15 December 2008



Hi Fabrice
when I had to choose a tag I noted that there was a format tag. So I went it and saw your CF.
Better than mine because not recursive, but younger than mine ( at that times April 7, 2006 [ vs your Nov 2007 ] I too was younger ! )
(Edited by Daniele Raybaudi on 15/12/08 )
  General comment
Fabrice
15 December 2008



LOL, we were all younger !
Actually, this recursive way has the advantage of a limitation of 10000, where Pad is limited to 404 characters only.
  General comment
comment
17 December 2008



The limit can be easily extended to 161,999 - see the RepeatPlus() function.
If you need more, just say so...
  General comment
Robert Schaub
27 February 2009



The parameter char is not accepted in FileMaker 10 because there is a new function withthe same name.
  General comment

 

 

 

 

 

Top Tags

Text Parsing  (33)
List  (31)
Date  (28)
XML  (26)
Format  (23)
Sql  (22)
Dev  (20)
Debug  (17)
Interface  (15)
Layout  (15)
Text  (14)
Variables  (12)
Layout Objects  (11)
Filter  (11)
Design  (10)
Array  (7)