Removes the specified item from the specified structure.
See also StructClear, StructFind, StructInsert, StructIsEmpty, StructKeyArray, StructCount, StructKeyArray, 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> <basefont face="Arial, Helvetica" size=2> <body bgcolor="#FFFFD5"> <H3>StructDelete Function</H3> <P> This example uses the StructInsert and StructDelete functions. <!--- Establish parms for first time through ---> <CFPARAM NAME="firstname" DEFAULT="Mary"> <CFPARAM NAME="lastname" DEFAULT="Torvath"> <CFPARAM NAME="email" DEFAULT="mtorvath@allaire.com"> <CFPARAM NAME="phone" DEFAULT="777-777-7777"> <CFPARAM NAME="department" DEFAULT="Documentation"> <CFIF IsDefined("FORM.Delete")> <CFOUTPUT> Field to be deleted: #form.field# </CFOUTPUT> <P> <CFScript> employee=StructNew(); StructInsert(employee, "firstname", firstname); StructInsert(employee, "lastname", lastname); StructInsert(employee, "email", email); StructInsert(employee, "phone", phone); StructInsert(employee, "department", department); </CFScript> <CFOUTPUT> employee is a structure: #IsStruct(employee)# </CFOUTPUT> <CFSET rc = StructDelete(employee, "#form.field#", "True")> <CFOUTPUT> <P>Did I delete the field "#form.field#"? The code indicates: #rc# </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>