Brian Dunning's FileMaker Custom Functions

CountNLC ( TheTxT ; scope )

Count numbers or letters or characters in field/list

  Average rating: 4.3 (23 votes) Log in to vote

Barry leunge   Barry leunge

Share on Facebook Share on Twitter

  Sample input:
CountNLC ( /*Bike */4453/*-+dhdh>>>road//**/**/++""::}{}|||;"N" )
  Sample output:
4

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

// All spaces are trimmed from "TheTxT"for the special character count
// "L" = Letters / "N" = Numbers / "C" = character (without spaces)
// Usage: CountLNC(<>;"N") counts all the numbers is text.

New version thanks to EOS, Teg

 

Comments

eos   eos, Teg
Sep 10, 2014
Why don't you try

Case (
IsEmpty ( Filter ( scope ; "LNC" ) ) ;
"Invalid parameter" ;

Let ( [
L = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" ;
N = "0123456789" ;
textTrimmed = Upper ( TrimAll ( theText ; 1 ; 3 ) ) ;
theFilter = Case ( scope = "L" ; L ; scope = "N" ; N ; scope = "C" ; L & N )
] ;
Length ( Filter ( textTrimmed ; theFilter ) )
)

)

// Args are: theText, scope
 
Barry leunge   Barry leunge
Sep 10, 2014
Thanks EOS for the shortend code, the character bit was for special character so i adjusted it a bit:

Case (
IsEmpty ( Filter ( scope ; "LNC" ) ) ;
"Invalid parameter" ;

Let ( [
L = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" ;
N = "0123456789" ;
textTrimmed = Upper ( TrimAll ( thetxt ; 1 ; 3 ) ) ;
theFilter = Case ( scope = "L" ; L ; scope = "N" ; N ; scope = "C" ; L & N )
] ;

If(thefilter=L & N;
Length(textTrimmed)-
Length(Filter(textTrimmed;thefilter));Length(Filter(textTrimmed; thefilter))

)

)

)
 

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.

Under construction. Email me your wish list for improvements.