To add to this, you'll probably need to use chr(160) (or "nbsp;") because
spaces will be ignored by the browser.

tom

----- Original Message -----
From: "Chapman, Katrina" <[EMAIL PROTECTED]>
To: "CF-Talk" <[EMAIL PROTECTED]>
Sent: Friday, November 03, 2000 12:53 PM
Subject: RE: padding a variable


> That's not the queston boys.  He's not asking how to limit it to 30 but
how
> to force it up to 30.  IE I have a string that's only 22 chars long I need
> it to be thirty.
>
> Try this
>
> <CFSET foo = "my string less than 30">
> <CFOUTPUT>
> #foo# - #len(foo)#
> </CFOUTPUT>
> <BR>
> <CFIF Len(foo) GTe 30>
> <CFSET foo = Left(foo, 30)>
> <CFELSE>
> <CFSET to  = 30 - Len(foo)>
> <CFLOOP from="1" to="#to#" index="ii">
> <CFSET foo = foo & "@">
> </CFLOOP>
> </CFIF>
> <CFOUTPUT>
> #foo# - #len(foo)#
> </CFOUTPUT>
>
> Of course you can replace the @ with whatever char you want to use.
>
> --K
>
> -----Original Message-----
> From: Philip Arnold - ASP [mailto:[EMAIL PROTECTED]]
> Sent: Friday, November 03, 2000 5:23 AM
> To: CF-Talk
> Subject: RE: padding a variable
>
>
> > how do you pad a variable in CF.
> > for example how can I force a query.columnname to take up exactly 30
> > characters?
>
> Just using Left() won't work if you're using variable length fields
> (varchar)
>
> You could use Left(myColumn & RepeatString(" ", 30), 30)
>
> HTH
>
> Philip Arnold
> ASP Multimedia Limited
> T: +44 (0)20 8680 1133
>
> "Websites for the real world"
>


------------------------------------------------------------------------------------------------
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists or send a message 
with 'unsubscribe' in the body to [EMAIL PROTECTED]

Reply via email to