Well, it wasn't too difficult to pull off. Here is a rough, working example:
<cfquery name="list">
SELECT
Songs.songId
,Songs.songTitle
,Songs.presetCount
FROM
Songs
INNER JOIN SetLists
ON Songs.songId = SetLists.songId
WHERE
SetLists.showId = 8
AND
SetLists.setNumber = 1
ORDER BY
SetLists.setNumber
,SetLists.songPosition
</cfquery>
<cfset presetsInBank = 5>
<cfset presetsRemainingInBank = presetsInBank>
<cfset currentPreset = 1>
<table border="1">
<tr>
<th>Song</th>
<th>Preset<br>Count</th>
<th>Current<br>Preset</th>
<th>Presets<br>Remaining</th>
</tr>
<cfoutput query="list">
<cfif list.presetCount gt presetsRemainingInBank>
<!---This song won't fit in the current bank.--->
<!---Add presetsRemainingInBank to currentPreset.--->
<cfset currentPreset += presetsRemainingInBank>
<cfset presetsRemainingInBank = presetsInBank>
</cfif>
<cfset presetsRemainingInBank -= list.presetCount>
<tr>
<td>#list.songTitle#</td>
<td>#list.presetcount#</td>
<td>#currentPreset#</td>
<td>#presetsRemainingInBank#</td>
</tr>
<cfset currentPreset += list.presetCount>
</cfoutput>
</table>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Want to reach the ColdFusion community with something they want? Let them know
on the House of Fusion mailing lists
Archive:
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:331896
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm