Function overview
Prototype
ValidNr (
nr )
Parameters
nr
Description
Tags:
numbers
Test field on invalid characters, empty values and even the result of erroneous calculations (e.g. division by zero).
Function returns zero is the number is valid.
E-notation is not supported. This function also does not test on decimal points of commas.
Examples
Sample input
1. ValidNr (evaluate (lg (-9))) ;
2: ValidNr (158.36)
3: ValidNr(Evaluate (Case(1=2; 0)))
Sample output
1: result = -2 (Logarithm of negative number does not exist)
2: result = 0 (this means that the number is valid)
3: result = 1 (number is empty)
Function code
/* Function ValidNr(nr)
Function tests on usability of number.
Function returns 0 if nr is valid;
+1 if nr is empty,
-1 is nr has nonnumerical characters,
-2 if nr is unavailable (e.g. the result of division by zero)
J.C. Roeloffzen, 18 jun 2010
feedback to: j.c.roeloffzen@rug.nl
*/
Let([
nrString = Trim(GetAsText(nr))];
Case(
IsEmpty( nrString ); 1;
nr ≠ 0 and nr/nr > 2; -2;
nrString ≠ Filter(nrString; "0123456789+-.,"); -1;
0)
)
// ===================================
/*
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/259
Prototype: ValidNr( nr )
Function Author: J.C. Roeloffzen (http://www.fmfunctions.com/mid/251)
Last updated: 18 June 2010
Version: 1.1
*/
// ===================================
/* Function ValidNr(nr)__LITBR____LITBR__Function tests on usability of number.__LITBR____LITBR__Function returns 0 if nr is valid;__LITBR__+1 if nr is empty,__LITBR__-1 is nr has nonnumerical characters,__LITBR__-2 if nr is unavailable (e.g. the result of division by zero)__LITBR____LITBR__J.C. Roeloffzen, 18 jun 2010 __LITBR____LITBR__feedback to: j.c.roeloffzen@rug.nl__LITBR__*/__LITBR____LITBR__Let([__LITBR__nrString = Trim(GetAsText(nr))];__LITBR____LITBR__Case(__LITBR__IsEmpty( nrString ); 1;__LITBR__nr ≠ 0 and nr/nr > 2; -2;__LITBR__nrString ≠ Filter(nrString; "0123456789+-.,"); -1;__LITBR__0)__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/259__LITBR____LITBR__ Prototype: ValidNr( nr )__LITBR__ Function Author: J.C. Roeloffzen (http://www.fmfunctions.com/mid/251)__LITBR__ Last updated: 18 June 2010__LITBR__ Version: 1.1__LITBR____LITBR__*/__LITBR__// ===================================
Login or register to comment
Create a new account with fmcustomfunctions.com or login to post a comment.