Assign Array with Dynamic Variable Names

Ask a Question related to Coldfusion - Advanced Techniques, Design and Development.

  1. #1

    Default Assign Array with Dynamic Variable Names

    I have an 2 dimensional array that I want to assign to an 1 dimensional array
    with a dynamic Variable Name. I can set the newarray function, but I can not
    get the syntax right to assign the array:
    2d array - flag [element1] [element2]

    code:
    <cfset "flag_#element1#[#element2#]"=0>

    element1 is assign from a list and element2 is assign from looping thru a
    recordcount.

    Coldfusion gives me the following error:

    Invalid CFML construct found on line 259 at column 82.
    ColdFusion was looking at the following text:
    [




    JHCOLVI Guest

  2. Similar Questions and Discussions

    1. Dynamic variable names??? Please Help!
      So I'm making this application for accessing research data - lots of different data tables, each with it's own data columns. I have made the...
    2. Getting the best answer(WAS: How do you dynamically assign array names?)
      I think this touches on an issue that people should consider when they post to this list. Often people ask a question, and instead of asking for...
    3. How do you dynamically assign array names?
      Hi, I am trying to initialize a dynamically-named array, i.e. with the following test code (if I type "script.pl char" at the command prompt) I...
    4. Dynamic Variable Names
      I have a shopping cart page that allows a user to type in a new quantity and press a button. The quantities entered are in form text boxes with...
    5. assign a variable using reflection
      Hallo, I am trying to assign a variable using reflection, Does anyone know how this is done? Any suggestions would be appriciated.. ...
  3. #2

    Default Re: Assign Array with Dynamic Variable Names

    What happens when you try:
    <cfset flag [element1] [element2] = 0>

    You might also add the following to your code (above this line) and post the
    results here:
    <CFDUMP var="#element1#">
    <CFDUMP var="#element2#">
    <CFDUMP var="#flag#">

    Regards,
    -- MikeR


    MikerRoo Guest

  4. #3

    Default Re: Assign Array with Dynamic Variable Names

    I can run the 2d array fine, but I am finding that it takes a long time to run
    and it is almost impossible to get a cfdump of the 2d array. That is why I want
    to change it to a 1d array with a dynamic variable name. It runs faster and I
    can get a cfdump fine. But I am having problem getting the syntax right.

    JHCOLVI Guest

  5. #4

    Default Re: Assign Array with Dynamic Variable Names

    I'm sorry but there is not enough information here to help you.

    Can you post a sample of the existing data and the desired result. And/ Or
    post the code that creates and sets "flag", "element1", and "element2".

    And/Or post the requested dumps.

    Regards,
    -- MikeR


    MikerRoo Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

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 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139