Javascript and .substring( ) : Strange

yanomano's picture

I'am trying to parse an Adobe AES files with javascript. AES are text files that contain a color combo (generaly fives hexadecimals colors).You can download those files from http://kuler.adobe.com/.

However i have strange result with the .substring( ) function :

var result = new Object();
var tempList=new Array(); 
function (__structure HEXAStructure) main (__string ASE_String)
{
 
   //* Parse the string in an array
   tempList= ASE_String.split("#")             
 
   //* delete the first Index
   tempList=tempList.splice(1,tempList.length)   
 
   //* Extract the hexadecimal 6 digits
   for (var i in tempList){
      tempList[i]=tempList[i].substring(1,13)      
                  }
 
 
result.HEXAStructure=tempList;
return result;
}

the result is an array with five hexadecimal : All seems to be fine but when i count the 6 digits they are 12.... Probably because of ".substring(1,13)" but it's seems the are invisible characters... So it break the conversion to RGB (see attached JS parse ASE.qtz)

I'am forgetting something :) Any advice?

PreviewAttachmentSize
JS parse ASE.qtz21.02 KB
JS Strange.qtz15.46 KB

sbn..'s picture
Re: Javascript and .substring( ) : Strange

Off the top of my head, don't JS strings' indices start at zero, not one?

You may also have some sort of terminator or newline at the end.

yanomano's picture
Re: Javascript and .substring( ) : Strange

Yes you are right and this one part of the problem here : in this case ".substring( ) "doesn't work really well...and I try to understand why....Perhaps it is because of the string input that contain a lot of special characters. I was enable to publish it in the "comment windows" because it seems the kineme server don't accept certain specials characters associations (probably to prevent hacking;)