If you're displaying this in a browser, then HTML is likely the culprit, condensing multiple spaces into just one. Use non-breaking spaces (or wrap your output in <pre> tags) to get HTML to output multiple spaces.
On Mon, Aug 22, 2011 at 11:19 AM, Josh Cesana <joshuaces...@yahoo.com>wrote: > > I'm attemping to create a function that adds spaces either in front of or > behind a string. For example, I want this "test" string to have 6 spaces > after it, plus the 4 characters in "test" for a total of 10 characters. I > have an "align" variable for both left and right alignment for the spaces. > So far, the only result I get is 'test ' instead of 'test ' > > <CFSCRIPT> > > function spaceFiller(cell, fill, align) { > var newcell = ""; > if (len(cell) EQ 0) { > cell = " "; > } > newcell = cell; > for (i=1; i EQ len(fill - (len(cell))); i=i+1) { > if (align EQ "R") { > newcell = " " & newcell; > } else { newcell = newcell & " "; > } > > } > return (newcell); > } > </CFSCRIPT> > > <cfoutput> > 10 characters - align left: '#spaceFiller("test","10","L")#' > </cfoutput> > > The result I get is 'test ' and what I want is 'test ' > > Any help would be much appreciated - thanks in advance. > -J > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:346928 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm