我有一个结构,它给了我超过100个范围。我想将>>这些范围分成两部分,这样我就可以通过传递url变量以两个不同的间隔运行这些范围。
<cfdump var="#variables[dynVarName]#"> ---- Struct of scopes
<cfset howManyCustomScopes = listLen(structkeylist(variables[dynVarName],"|" ),"|" )>
<!--- looping over collection of scopes ---->
<cfloop collection="#variables[dynVarName]#" item="t">
<cfset tempurl = variables[dynVarName][t]["url"]>
<cfset tempurl = tempurl & "&retainCache=1">
<cfoutput>
<cfhttp url="#tempurl#" method="GET" resolveurl="false" timeout="4000">
#tempurl#<br>
<cfset scopesCachedCounter = scopesCachedCounter + 1>
<cfmodule template="#Request.Library.CustomTags.VirtualPath#Scheduler_LogDetail.cfm" Step="Funded Scopes Cache" Detail="#scopesCachedCounter#.- #t#" LogData="#tempurl#"></cfmodule>
</cfoutput>
</cfloop>
所以我想将这些范围分成两部分。知道如何在CF中做到这一点吗? 转储:给我一些类似的东西:
答案 0 :(得分:4)
好的,我们现在已经足够了。
这证明了一个潜在的解决方案:
source = {
key1 = "value1",
key2 = "value2",
key3 = "value3",
key4 = "value4",
key5 = "value5"
};
splitAt = structCount(source) \ 2;
first = {};
second = {};
structToPopulate = first;
for (key in source){
structToPopulate[key] = source[key];
if (structCount(structToPopulate) > splitAt){
structToPopulate = second;
}
}
writeDump([source,first,second]);