How to Create List in ColdFusion
Program:
<cfset
myList="sathiyaraj,raj,mani,kumar">
<br>listitem<br>
<cfoutput>
List value is
#myList#
</cfoutput>
<br>listlen<br>
<cfoutput>
List length
#listlen(myList)#
</cfoutput>
<br>listGetAt<br>
<cfset MyValue
= #trim(listGetAt(myList, 2))#>
<cfoutput>
List position
second value is #MyValue#
</cfoutput>
<br>listSetAt<br>
<cfset
myNewList = ListSetAt(myList, 2, "senthil", ",")>
<cfoutput>
New List value is
#myNewList#
</cfoutput>
<br>listInsertAt<br>
<cfset
myNewList1 = ListInsertAt(myList, 3, "Kannan", ",")>
<cfoutput>
New List value is
#myNewList1#
</cfoutput>
<br>ListAppend<br>
<cfset
myNewList2 = ListAppend(myList, "Sundar")>
<cfoutput>
New List value is
#myNewList2#
</cfoutput>
<br>Listprepend<br>
<cfset
myNewList3 = Listprepend(myList, "Suresh")>
<cfoutput>
New List value is
#myNewList3#
</cfoutput>
output :
listitem
List value is sathiyaraj,raj,mani,kumar
listlen
List length 4
listGetAt
List position second value is raj
listSetAt
New List value is sathiyaraj,senthil,mani,kumar
listInsertAt
New List value is sathiyaraj,raj,Kannan,mani,kumar
ListAppend
New List value is sathiyaraj,raj,mani,kumar,Sundar
Listprepend
New List value is Suresh,sathiyaraj,raj,mani,kumar
List value is sathiyaraj,raj,mani,kumar
listlen
List length 4
listGetAt
List position second value is raj
listSetAt
New List value is sathiyaraj,senthil,mani,kumar
listInsertAt
New List value is sathiyaraj,raj,Kannan,mani,kumar
ListAppend
New List value is sathiyaraj,raj,mani,kumar,Sundar
Listprepend
New List value is Suresh,sathiyaraj,raj,mani,kumar
Comments
Post a Comment