>- see footer for list info -<
Well, FWIW turns out that making a generic bitmask, and not a date-based
bitmask was the way to go (code below, if you're interested). And then
use the code the Neil posted to store the bitmask values so they comply
with the values from the db.

Thanks all.


==== Bitmask.cfc ====
<cfcomponent output="no">
        <cfset setBitmask(0)>
        <cfset setLength(12)>
        
        <cffunction name="addValue" returntype="void" output="false">
                <cfargument name="iValue" type="numeric" required="yes">
                <cfset setBitmask(getBitmask() + (2 ^ (arguments.iValue
- 1)))>
        </cffunction>

        <cffunction name="getBitmask" returntype="numeric"
output="false">
                <cfreturn variables.iBitmask>
        </cffunction>
        
        <cffunction name="getLength" returntype="numeric"
output="false">
                <cfreturn variables.iLength>
        </cffunction>
        
        <cffunction name="getValues" returntype="array" output="false">
                <cfset var iVal = getBitmask()>
                <cfset aValues = arrayNew(1)>
                
                <cfloop from="#getLength()#" to="1" index="i" step="-1">
                        <cfif iVal gte 2 ^ (i - 1)>
                                <cfset arrayPrepend(aValues, i)>
                                <cfset iVal = iVal - (2 ^ (i - 1))>
                                <cfif not iVal>
                                        <cfbreak>
                                </cfif>
                        </cfif>
                </cfloop>
                
                <cfreturn aValues>
        </cffunction>
        
        <cffunction name="setBitmask" returntype="void" output="false">
                <cfargument name="iBitmask" type="numeric"
required="yes">
                <cfset variables.iBitmask = arguments.iBitmask>
        </cffunction>
        
        <cffunction name="setLength" returntype="void" output="false">
                <cfargument name="iLength" type="numeric"
required="yes">
                <cfset variables.iLength = arguments.iLength>
        </cffunction>
</cfcomponent>



==== bitmask.cfm ====
<cfset dTomorrow = dateAdd("d", 1, now())>
<cfset oBitmask = createObject("component", "Bitmask")>
<cfset oBitmask.setLength(7)>
<cfset oBitmask.addValue(iif(dayOfWeek(dTomorrow) eq 1, 7,
dayOfWeek(dTomorrow) - 1))>

<cfdump var="#oBitmask.getValues()#">



-- 
Aidan Whitehall   [EMAIL PROTECTED]
Macromedia ColdFusion Developer
Fairbanks Environmental   +44 (0)1695 51775

________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________
_______________________________________________

For details on ALL mailing lists and for joining or leaving lists, go to 
http://list.cfdeveloper.co.uk/mailman/listinfo

--
CFDeveloper Sponsors:-
>- Hosting provided by www.cfmxhosting.co.uk -<
>- Forum provided by www.fusetalk.com -<
>- DHTML Menus provided by www.APYCOM.com -<
>- Lists hosted by www.Gradwell.com -<
>- CFdeveloper is run by Russ Michaels, feel free to volunteer your help -<

Reply via email to