Here it is... the guys on this list should be able to understand it's usage. (If anyone wants to help document... that would be great also.) This version is somewhat tested... but don't have a full QA on this, so let me know if you find any "fixes" or "enhancements".

Thanks again,

John Farrar


---------------------------------------------------------- You are subscribed to cfcdev. To unsubscribe, send an email to [email protected] with the words 'unsubscribe cfcdev' as the subject of the email.

CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting 
(www.cfxhosting.com).

An archive of the CFCDev list is available at
www.mail-archive.com/[email protected]
<cfcomponent displayname="QueryIterator" output="false">
        <!--- This CFC is the property of SOSensible. You may use it free of 
charge under standard 
        GNU Open Source Lisc. practices. You may use it for personal or 
commercial and modify it
        to your needs at no charge. The only exceptions are that you may not 
remove this notice and
        you must not hold our company or employees liable in any way for it's 
performance. If you enhance
        this component we request that you send a copy of your enhancements to 
us at [EMAIL PROTECTED]
        for our review so that the spirit of this open source object will 
continue to grow for the 
        community at large.
        www.sosensible.com --->
        <cfset variables.query = queryNew("empty","VarChar")>
        <cfset variables.currentRow = 0>
        <cfset variables.recordCount = 0>
        <cfset variables.columnList = "">
        
        <cffunction name="init" access="public" returntype="any" output="false">
                <cfargument name="query" type="query" required="yes">
                <cfset var local = structNew()>
                
                <cfscript>
                variables.query = duplicate(arguments.query);
                variables.columnList = arguments.query.columnList;
                variables.currentRow = 1;
                variables.recordCount = arguments.query.recordCount;
                setAttributes();
                </cfscript>
                
                <cfreturn this>
        </cffunction>
        
        <cffunction name="getColumnList" access="public" returntype="numeric" 
output="false">
                <cfreturn variables.columnList>
        </cffunction>
        
        <cffunction name="getCurrentRow" access="public" returntype="numeric" 
output="false">
                <cfreturn variables.currentRow>
        </cffunction>
        
        <cffunction name="getRecordCount" access="public" returntype="numeric" 
output="false">
                <cfreturn variables.recordCount>
        </cffunction>
        
        <cffunction name="getRecordSet" access="public" returntype="query" 
output="false">
                <cfreturn variables.query>
        </cffunction>
        
        <cffunction name="hasNext" access="public" returntype="boolean" 
output="false">
                <cfreturn (variables.currentRow lt variables.query.recordCount)>
        </cffunction>
        
        <cffunction name="hasPrevious" access="public" returntype="boolean" 
output="false">             
                <cfreturn (variables.currentRow gt 1)>
        </cffunction>
        
        <cffunction name="isFirst" access="public" returntype="boolean" 
output="false">
                <cfreturn (variables.currentRow EQ 1)>
        </cffunction>
        
        <cffunction name="isLast" access="public" returntype="boolean" 
output="false">
                <cfreturn (variables.currentRow EQ variables.query.recordCount)>
        </cffunction>
        
        <cffunction name="moveFirst" access="public" returntype="boolean" 
output="false">
                <cfset var local = structNew()>
                
                <cfif variables.recordCount GTE 1>
                        <cfset variables.currentRow = 1>
                        <cfset local.myReturn = TRUE>
                        <cfset setAttributes()>
                <cfelse>
                        <cfset local.myReturn = FALSE>
                </cfif>
                
                <cfreturn local.myReturn>
        </cffunction>
        
        <cffunction name="moveLast" access="public" returntype="boolean" 
output="false">
                <cfset var local = structNew()>
                
                <cfif variables.recordCount GTE 1>
                        <cfset variables.currentRow = variables.recordCount>
                        <cfset local.myReturn = TRUE>
                        <cfset setAttributes()>
                <cfelse>
                        <cfset local.myReturn = FALSE>
                </cfif>
                
                <cfreturn local.myReturn>
        </cffunction>
        
        <cffunction name="moveNext" access="public" returntype="boolean" 
output="false">
                <cfset var local = structNew()>
                
                <cfif hasNext()>
                        <cfset variables.currentRow = variables.currentRow + 1>
                        <cfset local.myReturn = TRUE>
                        <cfset setAttributes()>
                <cfelse>
                        <cfset local.myReturn = FALSE>
                </cfif>
                
                <cfreturn local.myReturn>
        </cffunction>
        
        <cffunction name="movePosition" access="public" returntype="boolean" 
output="false">
                <cfargument name="position" type="numeric" required="Yes">
                <cfset var local = structNew()>
                
                <cfif arguments.position LTE getRecordCount()>
                        <cfset variables.currentRow = arguments.position>
                        <cfset local.myReturn = TRUE>
                        <cfset setAttributes()>
                <cfelse>
                        <cfset local.myReturn = FALSE>
                </cfif>
                
                <cfreturn local.myReturn>
        </cffunction>
        
        <cffunction name="movePrevious" access="public" returntype="boolean" 
output="false">
                <cfset var local = structNew()>
                
                <cfif hasPrevious()>
                        <cfset variables.currentRow = variables.currentRow - 1>
                        <cfset local.myReturn = TRUE>
                        <cfset setAttributes()>
                <cfelse>
                        <cfset local.myReturn = FALSE>
                </cfif>
                
                <cfreturn local.myReturn>
        </cffunction>
        
        <cffunction name="setAttributes" access="private" returntype="boolean" 
output="No">
                <cfset var local = structNew()>
                <cfset local.myReturn = TRUE>
                <cftry>
                <cfloop index="columnName" list="#variables.columnList#">
                        <cfset "this.#columnName#" = 
variables.query[columnName][variables.currentRow]>
                </cfloop>
                <cfcatch>
                        <cfset local.myReturn = FALSE>
                </cfcatch>
                </cftry>
                
                <cfreturn local.myReturn>
        </cffunction>
</cfcomponent>

----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email to 
[email protected] with the words 'unsubscribe cfcdev' as the subject of the 
email.

CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting 
(www.cfxhosting.com).

An archive of the CFCDev list is available at
www.mail-archive.com/[email protected]

Reply via email to