Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <cffunction name="getSignInfo" returntype="struct">
- <cfargument name="message" type="string" required="yes">
- <cfargument name="width" type="numeric" required="yes">
- <cfset CheapAssLine = ''>
- <cfset trimmedLetters = replace(arguments.message," ","","all") />
- <cfset words = listToArray(message, ' ')>
- <cfset letters = structNew()>
- <cfset letterArray = trimmedLetters.toCharArray()>
- <cfloop array="#letterArray#" index="alphabet">
- <cfif not structKeyExists(letters, alphabet)>
- <cfscript>
- StructInsert(letters, alphabet, '1');
- </cfscript>
- <cfelse>
- <cfset letters[alphabet] = letters[alphabet] + 1>
- </cfif>
- </cfloop>
- <cfset lineFeed = "<br />"&chr(13)&chr(10)>
- <cfset rowcount = 1>
- <cfset CheapAssRows = structNew()>
- <cfloop array="#words#" index="CheapAssWord">
- <cfif (len(CheapAssWord) + len(CheapAssLine)) lte (arguments.width)>
- <cfset CheapAssLine = CheapAssLine & CheapAssWord & ' '>
- <cfset CheapAssRows['Row ' & rowcount & ':'] = CheapAssLine>
- <cfelse>
- <cfset rowcount++>
- <cfset CheapAssLine = ''>
- <cfset CheapAssLine = CheapAssLine & CheapAssWord & ' '>
- <cfset CheapAssRows['Row ' & rowcount & ':'] = CheapAssLine>
- </cfif>
- </cfloop>
- <cfset JoesSignage = structNew()>
- <cfset JoesSignage.Rows = CheapAssRows>
- <cfset JoesSignage.Letters = letters>
- <cfreturn JoesSignage>
- </cffunction>
- <cfif isDefined("form.fieldNames")>
- <cfset JoesSignage = getSignInfo(form.message, form.slots)>
- <cfdump var="#JoesSignage#">
- </cfif>
- <form action="" method="post">
- <label for="message">Message:</label>
- <input name="message" id="message" type="text" value="Jar Jar Sucks Ewoks"/>
- <br/>
- <label for="slots">Slots:</label>
- <input name="slots" id="slots" type="text" value="10"/>
- <br/>
- <input name="go" type="submit" value="Go"/>
- </form>
Advertisement
Add Comment
Please, Sign In to add comment