-
Notifications
You must be signed in to change notification settings - Fork 0
/
customTag.cfm
51 lines (34 loc) · 968 Bytes
/
customTag.cfm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<CFSWITCH EXPRESSION="#attributes.functionLibrary#">
<CFCASE VALUE="numberSequencer">
<CFFUNCTION NAME="numberSequencer" RETURNTYPE="array" OUTPUT="true" ACCESS="public">
<CFARGUMENT NAME="argN" TYPE="numeric" REQUIRED="yes">
<CFARGUMENT NAME="argM" TYPE="numeric" REQUIRED="yes">
<CFARGUMENT NAME="argEnd" TYPE="numeric" REQUIRED="yes">
<CFSCRIPT>
//function numberSequencer(argN,argM,argEnd) {
//initialise variables
var n = ARGUMENTS.argN;
var m = ARGUMENTS.argM;
var end = ARGUMENTS.argEnd;
var sequence = ArrayNew(1);
sequence[1] = n;
sequence[2] = m;
for(i = 3;i lte end;i=i+1){
sequence[i] = sequence[i-1] + sequence[i-2];
if(sequence[i] EQ end){
break;
}
else if(sequence[i] GT end){
ArrayDeleteAt(sequence,i);
break;
}
}
return sequence;
//}
</CFSCRIPT>
<CFRETURN sequence>
</CFFUNCTION>
<CFSET result = numberSequencer(ATTRIBUTES.argN,ATTRIBUTES.argM,ATTRIBUTES.argEnd)>
<CFSET "CALLER.#ATTRIBUTES.sequence#" = result>
</CFCASE>
</CFSWITCH>