Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6600903
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T18:41:03+00:00 2026-05-25T18:41:03+00:00

In versions of ColdFusion prior to 8 the duplicate function throws an error if

  • 0

In versions of ColdFusion prior to 8 the duplicate function throws an error if there are any components in the structure. In 8 and beyond it will work, but there are issues when copying components.

So, What I need is a way to create a deep copy of a structure that ignores components. For my purposes it’s for debugging, I need a snapshot of the variables scope at a particular point in the code, so efficiency doesn’t really matter as this will never make it out of the development environment. Currently using CF 7, I would take what 8 offers if only to solve this immediate issue, but I don’t control upgrade 🙁

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T18:41:04+00:00Added an answer on May 25, 2026 at 6:41 pm

    While you were off killing brain cells, I took a stab at a recursive function 😉 It excludes components and java/com objects. Neither of which MX7 can duplicate. I threw the functions into a component to avoid tampering with the variables scope. Then stored the instance in the request scope.

    It is not rigorously tested. So I am sure there is room for improvement.

    Usage

    <cfset request.util = createObject("component", "Util")>
    <cfset request.copy = request.util.duplicateStructMinusObjects(variables)>
    <cfdump var="#request.copy#">
    

    Util.cfc

    <cfcomponent>
        <cfscript>
                function duplicateArrayMinusObjects(input) {
                        var x      = "";
                        var value  = "";
                        var output = arrayNew(1);
    
                        for (x = 1; x lte arrayLen(arguments.input); x = x + 1) {
                                value = arguments.input[x];
    
                                // note components are considered structures
                                if (IsStruct(value) and not IsObject(value)) {
                                        arrayAppend(output, duplicateStructMinusObjects(value));
                                }
                                else if (IsArray(value)) {
                                        arrayAppend(output, duplicateArrayMinusObjects(value));                
                                }
                                else if (not IsObject(value)){        
                                        arrayAppend(output, duplicate(value));
                                }
                        }        
                        return output;
                }
    
                function duplicateStructMinusObjects(input) {
                        var key    = "";
                        var value  = "";
                        var output = structNew();
    
                        for (key in arguments.input) {
                                value = arguments.input[key];
    
                                // note components are considered structures
                                if (IsStruct(value) and not IsObject(value)) {
                                        output[key] = duplicateStructMinusObjects(value);
                                }
                                else if (IsArray(value)) {
                                        output[key] = duplicateArrayMinusObjects(value);
                                }
                                else if (not IsObject(value)){        
                                        output[key] = duplicate(value);
                                }
                        }
    
                        return output;
                }
        </cfscript>
    </cfcomponent> 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The newer versions of ColdFusion (I believe CF 8 and 9) allow you to
In ColdFusion version 9, I have the following in Index.cfm: <cfdump var=#Application#> But the
Many versions of Delphi including Delphi 2010 display Error executing 'D:\ProgramData{BBD31133-40F8-4B57-9BA6-DB76C03D153B}\Setup.exe': The parameter is
In prior versions of Windows before Vista you could have a Windows Service interact
Is there something built into Coldfusion that would let me know the browser and
I'm a coldfusion developer but I've been handed a Joomla website (PHP) with a
I'm starting some work on an existing ColdFusion application with no version control and
I'm working on a project that will (soon) be branched into multiple different versions
Is there a ColdFusion equivalent of phpinfo()? I don't know much about ColdFusion except
Older versions of the .Net Framework used to install Microsoft .NET Framework v1.0 /

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.