Created
October 26, 2012 19:32
-
-
Save orangexception/3960946 to your computer and use it in GitHub Desktop.
A Quick Refactor for Mike Henke
This file contains hidden or 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
# A Quick Refactor for Mike Henke | |
<!--- Transforms a query of names into an oddly formatted string. | |
# Example | |
Query | |
`First` `Last` | |
Bradley Moore | |
Wayne Moore | |
Orange Exception | |
Output | |
`Bradley, Wayne Moore and Orange Exception` | |
---> | |
<cfset qMinorList= MinorList /> | |
<cfif qMinorList.RecordCount EQ 1> | |
<cfset sMinorNames= qMinorList.First & " " & qMinorList.Last /> | |
<cfelse> | |
<cfloop query= "qMinorList"> | |
<!--- First Record ---> | |
<cfif qMinorList.CurrentRow EQ 1> | |
<cfset sMinorNames= qMinorList.First /> | |
<cfset sLastHold= TRIM( qMinorList.Last ) /> | |
<!--- Middle Records ---> | |
<cfelseif qMinorList.CurrentRow LT qMinorList.RecordCount> | |
<cfif Compare( sLastHold , qMinorList.Last ) EQ 0> | |
<cfset sMinorNames&= ", " & qMinorList.First /> | |
<cfelse> | |
<cfset sMinorNames&= " " & sLastHold & "," /> | |
<cfset sLastHold= TRIM( qMinorList.Last ) /> | |
</cfif> | |
<!--- Last Record ---> | |
<cfelse> | |
<cfif Compare( sLastHold , qMinorList.Last ) NEQ 0> | |
<cfset sMinorNames&= " " & sLastHold /> | |
</cfif> | |
<cfset sMinorNames&= " and " & qMinorList.First & " " & qMinorList.Last /> | |
</cfif> | |
</cfloop> | |
</cfif> | |
<cfset minornames= sMinorNames /> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment