Not sure what you would use this for... But here goes:


<cfset intLength = 150 />

<cfset intCounterHeight = Len( intLength ) />



<cfset arrOutput = ArrayNew( 2 ) />

<cfloop index="intI" from="1" to="#intLength#">

        <cfif (intI MOD 10)>
        
                <cfloop index="intR" from="1" to="#intCounterHeight#">
                        
                        <cfset arrOutput[ intR ][ intI ] = " " />
                
                </cfloop>
        
                <cfset arrOutput[ intCounterHeight ][ intI ] = (intI MOD
10) />
        
        <cfelse>
        
                <cfset strValue = RJustify( intI, intCounterHeight ) />
                
                <cfloop index="intR" from="1" to="#intCounterHeight#">
                        
                        <cfset arrOutput[ intR ][ intI ] = Mid(
strValue, intR, 1 ) />
                
                </cfloop>
        
        </cfif> 

</cfloop>


<cfset sbOutput = CreateObject( "java", "java.lang.StringBuffer"
).Init() />

<cfloop index="intR" from="1" to="#intCounterHeight#">
        
        <cfloop index="intC" from="1" to="#intLength#">
                
                <cfset sbOutput.Append( ToString( arrOutput[ intR ][
intC ] ) ) />
        
        </cfloop>       
        
        <cfset sbOutput.Append( "<br />" ) />

</cfloop>


<pre>#sbOutput.ToString()#</pre> 




......................
Ben Nadel
Certified Advanced ColdFusion MX7 Developer
www.bennadel.com
 
Need ColdFusion Help?
www.bennadel.com/ask-ben/

-----Original Message-----
From: Paul Vernon [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, December 20, 2006 11:19 AM
To: CF-Talk
Subject: ASCII ruler

Hi all,

I've Googled for two days but just cannot find anything to do what I
need and for some reason my brain is having a block on writing the code
that actually works...

Essentially, I have a need to show an ascii ruler of arbitrary length on
screen the output would resemble this.... (I hope it doesn't wrap)

                                                    1         1
         1         2         3            9         0         1
1234567890123456789012345678901234.....7890123456789012345678901234.....
..


My brain is looking at nested loops with MOD 10 calculations but the
output just turns into a mess resembling my brain which is slowly
turning into mush.

If anyone can point me in the direction of a decent algorithm in *any*
language that would do this I would be eternally grateful!

Paul





~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Create robust enterprise, web RIAs.
Upgrade & integrate Adobe Coldfusion MX7 with Flex 2
http://ad.doubleclick.net/clk;56760587;14748456;a?http://www.adobe.com/products/coldfusion/flex2/?sdid=LVNU

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:264613
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4

Reply via email to