Re: CFScript help

2011-08-22 Thread Josh Cesana

Thanks all - the built in function is exactly what I needed. I am fairly new to 
CF so I will definitely spend time learning the functions. Thanks again. 

~|
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:346933
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


CFScript help

2011-08-22 Thread Josh Cesana

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  '


 
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);
}



10 characters - align left: '#spaceFiller("test","10","L")#'


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:346926
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm