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 - Show more from this author

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.

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: