if (fb_.verbInfo.executionMode is "start") { // validate attributes fb_.nAttrs = 0; // there are five different forms of the verb: // 1. condition - string - required // 2. query - string - required // 3. from - string - required // to - string - required // index - string - required // step - string - optional // 4. collection - string - required // item - string - required // 5. list - string - required // index - index - required // the last two are new in Fusebox 5 if (structKeyExists(fb_.verbInfo.attributes,"condition")) { fb_.nAttrs = 1; fb_appendLine(''); } else if (structKeyExists(fb_.verbInfo.attributes,"query")) { fb_.nAttrs = 1; fb_appendLine(''); } else if (structKeyExists(fb_.verbInfo.attributes,"from") or structKeyExists(fb_.verbInfo.attributes,"to")) { fb_.nAttrs = 3; // from/to/index required if (not structKeyExists(fb_.verbInfo.attributes,"from") or not structKeyExists(fb_.verbInfo.attributes,"to") or not structKeyExists(fb_.verbInfo.attributes,"index")) { fb_throw("fusebox.badGrammar.requiredAttributeMissing", "Required attribute is missing", "The attributes 'from', 'to' and 'index' are both required, for a 'loop' verb in fuseaction #fb_.verbInfo.circuit#.#fb_.verbInfo.fuseaction#."); } else { fb_appendSegment('<' & 'cfloop from="#fb_.verbInfo.attributes.from#"' & ' to="#fb_.verbInfo.attributes.to#"' & ' index="#fb_.verbInfo.attributes.index#"'); if (structKeyExists(fb_.verbInfo.attributes,"step")) { fb_.nAttrs = fb_.nAttrs + 1; // step optional fb_appendSegment(' step="#fb_.verbInfo.attributes.step#"'); } fb_appendLine('>'); } } else if (structKeyExists(fb_.verbInfo.attributes,"collection")) { fb_.nAttrs = 2; // collection/item required if (not structKeyExists(fb_.verbInfo.attributes,"item")) { fb_throw("fusebox.badGrammar.requiredAttributeMissing", "Required attribute is missing", "The attribute 'item' is required, for a 'loop' verb with a 'collection' attribute in fuseaction #fb_.verbInfo.circuit#.#fb_.verbInfo.fuseaction#."); } else { fb_appendLine(''); } } else if (structKeyExists(fb_.verbInfo.attributes,"list")) { fb_.nAttrs = 2; // list/index required if (not structKeyExists(fb_.verbInfo.attributes,"index")) { fb_throw("fusebox.badGrammar.requiredAttributeMissing", "Required attribute is missing", "The attribute 'index' is required, for a 'loop' verb with a 'list' attribute in fuseaction #fb_.verbInfo.circuit#.#fb_.verbInfo.fuseaction#."); } else { fb_appendLine(''); } } else { // illegal attributes fb_throw("fusebox.badGrammar.requiredAttributeMissing", "Required attribute is missing", "One of 'condition', 'query', 'from'/'to', 'collection' or 'list' is required, for a 'loop' verb in fuseaction #fb_.verbInfo.circuit#.#fb_.verbInfo.fuseaction#."); } // strict mode - check attribute count: if (fb_.verbInfo.action.getCircuit().getApplication().strictMode) { if (structCount(fb_.verbInfo.attributes) neq fb_.nAttrs) { fb_throw("fusebox.badGrammar.unexpectedAttributes", "Unexpected attributes", "Unexpected attributes were found in a 'loop' verb in fuseaction #fb_.verbInfo.circuit#.#fb_.verbInfo.fuseaction#."); } } } // compile if (fb_.verbInfo.executionMode is "end") { fb_appendLine(""); }