3 Replies Latest reply on Sep 1, 2008 8:38 AM by kglad

    construct Array name dynamically / Part4

    luciewong Level 1
      part 4>
      the code line in Part 3 / line above (contains(un.....(this["colName"]));

      >>(un... ,,should be the word >even again I cannot write it / so I try [ its the opposite of "escape"] < was not accepted / is a censored word<
      very funny guys / but not my fault

      so I continue with my code, what a time waste

      var noAmp:String = realString.split(amp).join("&").toString();
      var theColumn:String = noAmp;//.toString();

      Above works, I get now for ex. a column name like > "Art >ampersand< Design"<

      but my Array construction as before does not work anymore>

      _root[theTable+[theColumn]+"_array"] = new Array();//< returns undefined<<<<

      the Array would look like:

      _root["GaleriesArt >ampersand< Design_array"] = new Array();

      How can I construct the Array name including the >ampersand< wow??

      Really appreciate your help and thanks for your patience, blame Adobe.
      Thanks
        • 1. Re: construct Array name dynamically / Part4
          kglad Adobe Community Professional & MVP
          you can't have an ampersand in a variable or object name.
          • 2. construct Array name dynamically / Part4
            luciewong Level 1
            Hi kglad,
            unfortunately I must have it, bec data comes from a Client DB, and they have >ampersands< in column names and in Field values.
            I've got it to work with the code below.

            All the code is included in the LV (success){

            var zi:Number = 0;//

            while(zi<recsT){ //<no of columns<

            var amp = "&amp;";
            var realString:String = new String(un..>censored word<,,,escape(this["cName"+zi]));
            var noAmp:String = realString.split(amp).join("&").toString();

            var thecolName:String = noAmp;
            col_array.push(thecolName);//I have now a array with all column names (some also include "&")

            var colName:String = thecolName.toString();//not sure if necc.

            //<I construct now new different arrays for each column 1 including "&" in the name
            _root[Table+colName+"_array"] = new Array();

            zi = zi+1;
            }


            //in the new created arrays I wonna have now the values/all values in 1 column/then the next>

            for(var xb:Number = 0;xb<recsT;xb++){ //<<the no of columns<
            var theName:String = col_array[xb].toString();

            var dd:Number = 0;
            while(dd<recsNo){ //<how many recs[rows/pages] I have for this Table?

            _root[Table+[theName]+"_array"].push(un...<you know the censored word>..escape(this[theName+dd]));
            dd=dd+1;//
            }
            }
            //end of for

            I can now access the dynamic arrays and write out all values, some including >&<.

            Thank you for your interest and your help
            Bye,
            Lucie

            Ps.:
            I have now only 1 issue left, the values have Spanish and French and German Characters and they come out woppy.
            Do you know some code to fix this, only un.....escape does not do the job.
            Thanks.
            • 3. Re: construct Array name dynamically / Part4
              kglad Adobe Community Professional & MVP
              there's never a need for having an ampersand as part of a variable name or object name.

              if you need it for a variable value and it (or any other symbol like foreign language characters and certain other punctuation symbols) is "translated" after loading from an external source, you can always use split(translated symbol).join(desired symbol).