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
*/
// ===================================
* __LITBR__Author: AnKe__LITBR__Skopelos Island, Greece, March 2009__LITBR____LITBR__Based on the Daniele Raybaudi's Function Format Write ( char ; times )__LITBR____LITBR__Parameters__LITBR__ String: Any number or text__LITBR__ FillChar: Any character to fill__LITBR__ Len: The desired legth of the resulted string__LITBR__ LR_Flag: When its value is 1 the number is padded Left, i.e. Trailing chars are added__LITBR__ When its value is 2 the number is padded Right, i.e. Leading chars are added__LITBR____LITBR__ The functions returns a string of fixed length, defined by Len, with Leading or Trailing chars, defined by FillChar__LITBR__ and the value of LR_Flag__LITBR____LITBR__If the Length of the String exceeds Len the string unaltered is returnd__LITBR__*/__LITBR____LITBR__Case ( LR_Flag = 1 ; __LITBR__ Case (__LITBR__ Length ( GetAsText ( String ) ) - Len < 0;__LITBR__ Static_Len (FillChar ; Len - 1; String; 1) & FillChar;__LITBR__ String__LITBR__ ); __LITBR__ Case (__LITBR__ Len - Length ( GetAsText ( String ) ) > 0;__LITBR__ FillChar & Static_Len (FillChar ; Len - 1; String; 2);__LITBR__ String__LITBR__ ) __LITBR__ )__LITBR____LITBR__// ===================================__LITBR__/*__LITBR____LITBR__ This function is published on FileMaker Custom Functions__LITBR__ to check for updates and provide feedback and bug reports__LITBR__ please visit http://www.fmfunctions.com/fid/222__LITBR____LITBR__ Prototype: Static_Length( String; Len; FillChar; LR_Flag )__LITBR__ Function Author: anke (http://www.fmfunctions.com/mid/179)__LITBR__ Last updated: 09 May 2009__LITBR__ Version: 1__LITBR____LITBR__*/__LITBR__// ===================================
Login or register to comment
Create a new account with fmcustomfunctions.com or login to post a comment.
Comments
09 May 2009