pastebin - collaborative debugging

pastebin is a collaborative debugging tool allowing you to share and modify code snippets while chatting on IRC, IM or a message board.

This site is developed to XHTML and CSS2 W3C standards. If you see this paragraph, your browser does not support those standards and you need to upgrade. Visit WaSP for a variety of options.

shayne private pastebin - collaborative debugging tool What's a private pastebin?


Posted by Shayne on Tue 11 Dec 18:18
report spam | download | new post

  1. <cfcomponent output="false">
  2.     <cfscript>
  3.         this.COUNTUP   = 1;
  4.         this.COUNTDOWN = 0;
  5.        
  6.         instance           = StructNew();
  7.         instance.delimiter = "";
  8.         instance.direction = 1;
  9.         instance.endNum    = 0;
  10.         instance.startNum  = 0;
  11.     </cfscript>
  12.    
  13.     <cffunction name="init" output="false" access="public">
  14.         <cfargument name="startNum" required="true" />
  15.         <cfargument name="endNum" required="true" />
  16.         <cfargument name="direction" default="-1" />
  17.         <cfscript>
  18.             setStartNum(arguments.startNum);
  19.             setEndNum(arguments.endNum);
  20.            
  21.             if (arguments.direction EQ -1) {
  22.                 if (arguments.startNum LTE arguments.endNum) {
  23.                     setCountUp();
  24.                 } else {
  25.                     setCountDown();
  26.                 }
  27.             } else {
  28.                 setDirection(arguments.direction);
  29.             }
  30.         </cfscript>
  31.         <cfreturn this />
  32.     </cffunction>
  33.    
  34.     <cffunction name="run" output="false" access="public">
  35.         <cfscript>
  36.             var output = "";
  37.             var i      = 0;
  38.             var start  = getStartNum();
  39.             var end    = getEndNum();
  40.             var doAbs  = false;
  41.            
  42.             if (getEndNum() LTE getStartNum()) {
  43.                 start = start * -1;
  44.                 end   = end * -1;
  45.             }
  46.            
  47.             for (i=start; i LTE end; i++) {
  48.                 output &= IIf(doAbs, Abs(i), i);
  49.                 if (hasDelimiter() AND i LT end) {
  50.                     output &= getDelimiter();
  51.                 }
  52.             }
  53.         </cfscript>
  54.         <cfreturn output />
  55.     </cffunction>
  56.    
  57.     <!--- Getters/Setters --->
  58.    
  59.     <cffunction name="getDirection" output="false" access="public">
  60.         <cfreturn instance.direction />
  61.     </cffunction>
  62.    
  63.     <cffunction name="setDirection" output="false" access="public">
  64.         <cfargument name="direction" required="true" />
  65.         <cfset instance.direction = arguments.direction />
  66.     </cffunction>
  67.    
  68.     <cffunction name="getEndNum" output="false" access="public">
  69.         <cfreturn instance.endNum />
  70.     </cffunction>
  71.    
  72.     <cffunction name="setEndNum" output="false" access="public">
  73.         <cfargument name="endNum" required="true" />
  74.         <cfset instance.endNum = arguments.endNum />
  75.     </cffunction>
  76.    
  77.     <cffunction name="hasDelimiter" output="false" access="public">
  78.         <cfreturn StructKeyExists(instance, "delimiter") AND Len(instance.delimiter) GT 0 />
  79.     </cffunction>
  80.    
  81.     <cffunction name="getDelimiter" output="false" access="public">
  82.         <cfreturn instance.delimiter />
  83.     </cffunction>
  84.    
  85.     <cffunction name="setDelimiter" output="false" access="public">
  86.         <cfargument name="delimiter" required="true" />
  87.         <cfset instance.delimiter = arguments.delimiter />
  88.     </cffunction>
  89.    
  90.     <cffunction name="getStartNum" output="false" access="public">
  91.         <cfreturn instance.startNum />
  92.     </cffunction>
  93.    
  94.     <cffunction name="setStartNum" output="false" access="public">
  95.         <cfargument name="startNum" required="true" />
  96.         <cfset instance.startNum = arguments.startNum />
  97.     </cffunction>
  98.    
  99.     <cffunction name="setCountUp" output="false" access="public">
  100.         <cfset setDirection(this.COUNTUP) />
  101.     </cffunction>
  102.    
  103.     <cffunction name="setCountDown" output="false" access="public">
  104.         <cfset setDirection(this.COUNTDOWN) />
  105.     </cffunction>
  106. </cfcomponent>

Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:

To highlight particular lines, prefix each line with @@


Remember me