Skip to content

Instantly share code, notes, and snippets.

@JamoCA
Created April 3, 2019 21:17
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JamoCA/e9fd556c3f7c01c5c4a23c44555ba411 to your computer and use it in GitHub Desktop.
Save JamoCA/e9fd556c3f7c01c5c4a23c44555ba411 to your computer and use it in GitHub Desktop.
Pass a variable name to determine if it exists and has len/arraylen/structcount/recordcount
<cfscript>
/* 11/28/2017 Checks to see if item exists and has len/arraylen/structcount/recordcount */
function ExistsLEN(theVariable){
var tempVal = "";
if (LEN(TRIM(theVariable)) AND isDefined(theVariable) AND isSimpleValue(theVariable)){
tempVal = evaluate(theVariable);
if (isSimpleValue(tempVal) AND LEN(trim(tempVal))){
return true;
} else if (isArray(tempVal) AND ArrayLen(tempVal)){
return true;
} else if (isStruct(tempVal) AND StructCount(tempVal)){
return true;
} else if (isQuery(tempVal) AND tempval.recordCount){
return true;
}
}
return false;
}
</cfscript>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment