Removes the specified item from the specified structure.
See also StructClear, StructFind, StructInsert, StructIsEmpty, StructKeyArray, StructCount, StructKeyExists, and StructUpdate.
StructDelete(structure, key [, indicatenotexisting ])
Structure containing the item to be removed.
Item to be removed.
Indicates whether the function returns FALSE if key does not exist. The default is FALSE, which means that the function returns Yes regardless of whether key exists. If you specify TRUE for this parameter, the function returns Yes if key exists and No if it does not.
<!------------------------------------------------------------------- This example shows how to use the StructDelete function. ---------------------------------------------------------------------> <html> <head> <title>StructDelete Function</title> </head> <BODY bgcolor="#FFFFD5"> <h3>StructDelete Function</h3> <h3>Delete a field from a structure</h3> <!--- This example shows how to use the StructDelete function. ---> <h3>StructDelete Function</h3><P> This example uses the StructInsert and StructDelete functions. <!--- Establish parms for first time through ---> <CFSET firstname="Mary"> <CFSET lastname="Torvath"> <CFSET email="mtorvath@allaire.com"> <CFSET phone="777-777-7777"> <CFSET department="Documentation"> <CFIF IsDefined("FORM.Delete")> <CFOUTPUT> <P>Field to be deleted: #form.field#</P> </CFOUTPUT> <CFSET employee=StructNew()> <CFSET rc=StructInsert(employee, "firstname", firstname)> <CFSET rc=StructInsert(employee, "lastname", lastname)> <CFSET rc=StructInsert(employee, "email", email)> <CFSET rc=StructInsert(employee, "phone", phone)> <CFSET rc=StructInsert(employee, "department", department)> <CFOUTPUT>employee is a structure: #IsStruct(employee)# <P>It has #StructCount(employee)# fields.</P> <CFSET rc=StructDelete(employee, form.field, "True")> <P>Did I delete the field "#form.field#"? The code indicates: #rc# </P> <P>It has #StructCount(employee)# fields now.</P> </CFOUTPUT> </CFIF> <CFIF NOT IsDefined("FORM.Delete")> <FORM action="structdelete.cfm" method="post"> <P>Select the field to be deleted: < SELECT name="field"> <OPTION VALUE="firstname">first name <OPTION VALUE="lastname">last name <OPTION VALUE="email">email <OPTION VALUE="phone">phone <OPTION VALUE="department">department </SELECT> <INPUT type="submit" name="Delete" value="Delete"> </FORM> </CFIF> </BODY> </HTML>