Static_Length ( )

Function stats

Average user rating
179
222
9999
Support
FileMaker 8.0 +
Date posted
09 May 2009
Version
1
Recursive function
Yes

Author Info
 anke

1 functions

Average Rating None

author_avatar



 

Function overview

Prototype

Static_Length  ( String;   Len;   FillChar;   LR_Flag )


Parameters

String  Any number or text


Len  The desired legth of the output string


FillChar  Any character to fill


LR_Flag  When its value is 1 the number is padded Left, i.e. Leading chars are added


Description

Tags:  format  

The functions returns a string of fixed length, defined by Len, with Leading or Trailing chars, defined by FillChar and the value of LR_Flag

If the Length of the String is greater than Len the string is returned unaltered

Examples

Sample input

Static_Length ("1234"; 10 ; "0" ; 2)


Sample output

0000001234

 

Function code

*
Author: AnKe
Skopelos Island, Greece, March 2009

Based on the Daniele Raybaudi's Function Format Write ( char ; times )

Parameters
String: Any number or text
FillChar: Any character to fill
Len: The desired legth of the resulted string
LR_Flag: When its value is 1 the number is padded Left, i.e. Trailing chars are added
When its value is 2 the number is padded Right, i.e. Leading chars are added

The functions returns a string of fixed length, defined by Len, with Leading or Trailing chars, defined by FillChar
and the value of LR_Flag

If the Length of the String exceeds Len the string unaltered is returnd
*/

Case ( LR_Flag = 1 ;
Case (
Length ( GetAsText ( String ) ) - Len < 0;
Static_Len (FillChar ; Len - 1; String; 1) & FillChar;
String
);
Case (
Len - Length ( GetAsText ( String ) ) > 0;
FillChar & Static_Len (FillChar ; Len - 1; String; 2);
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/222

    Prototype: Static_Length( String; Len; FillChar; LR_Flag )
    Function Author: anke (http://www.fmfunctions.com/mid/179)
    Last updated: 09 May 2009
    Version: 1

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

 

Comments

Fabrice
09 May 2009



this seems verymuch like a recursive version of Pad http://www.fmfunctions.com/fname/pad
  General comment

 

 


Login or register to comment

Create a new account with fmcustomfunctions.com or login to post a comment.

 

 

 

Top Tags

Text Parsing  (24)
List  (19)
XML  (15)
Format  (14)
Date  (14)
Debug  (12)
Layout  (11)
Variables  (10)
Filter  (9)
ValueIterator  (6)
Layout Objects  (6)
Number  (5)
Recursive  (5)
Dev  (5)
Interface  (5)
Text  (5)