Created
November 13, 2020 12:09
-
-
Save bennadel/4c634f607135dae90b6f50fc69fc9239 to your computer and use it in GitHub Desktop.
Adding Differ() And DifferNoCase() Built-In Function Extensions In Lucee CFML 5.3.7.47
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cfscript> | |
/** | |
* I determine if the two values are different use a CASE SENSITIVE operation. | |
* | |
* @valueA I am the first value to compare. | |
* @valueB I am the second value to compare. | |
*/ | |
public boolean function differ( | |
required string valueA, | |
required string valueB | |
) { | |
// The compare() method performs a CASE SENSITIVE operation and returns 0 if the | |
// values are the SAME; and, a non-zero result if the two values are different. | |
var isSameValue = ( compare( valueA, valueB ) == 0 ); | |
return( ! isSameValue ); | |
} | |
</cfscript> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cfscript> | |
/** | |
* I determine if the two values are different use a CASE INSENSITIVE operation. | |
* | |
* @valueA I am the first value to compare. | |
* @valueB I am the second value to compare. | |
*/ | |
public boolean function differNoCase( | |
required string valueA, | |
required string valueB | |
) { | |
// The compareNoCase() method performs a CASE INSENSITIVE operation and returns 0 | |
// if the values are the SAME; and, a non-zero result if the two values are different. | |
var isSameValue = ( compareNoCase( valueA, valueB ) == 0 ); | |
return( ! isSameValue ); | |
} | |
</cfscript> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cfscript> | |
// Testing prior to deploying the .lex file. | |
// -- | |
// include "./ext/functions/differ.cfm"; | |
// include "./ext/functions/differNoCase.cfm"; | |
echoMany( "differ( a, A ) →", differ( "a", "A" ) ); | |
echoMany( "differ( A, A ) →", differ( "A", "A" ) ); | |
echoMany( "differ( A, Z ) →", differ( "A", "Z" ) ); | |
echoMany(); | |
echoMany( "differNoCase( a, A ) →", differNoCase( "a", "A" ) ); | |
echoMany( "differNoCase( A, A ) →", differNoCase( "A", "A" ) ); | |
echoMany( "differNoCase( A, Z ) →", differNoCase( "A", "Z" ) ); | |
// ------------------------------------------------------------------------------- // | |
// ------------------------------------------------------------------------------- // | |
/** | |
* I collapse the variadic arguments down into a space-delimited list and echo them to | |
* the output. A <BR> tag is added automatically. | |
* | |
* @1...N Simple values to output. | |
*/ | |
public void function echoMany() { | |
echo( arrayToList( arguments, " " ) & "<br />" ); | |
} | |
</cfscript> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment