XML Feeds

.

[javascript-dev] Tasks and String manipulations

volker böhm vboehm at gmx.ch
Sun Mar 16 13:10:34 MDT 2008


On 16 Mar 2008, at 14:24, Garth Paine wrote:

> Thanks Volker
>
> Yes indeed I am doing it that way at the moment, but I wanted to  
> try it in
> JavaScript hence my clumsy attempts - I don't get to do much coding  
> these
> days and try to give myself the odd challenge - also I don't  
> generally see
> Max as good at iterative things although in this case you are right  
> it is
> quite straight forward - this is my MAX solution which works fine,  
> but any
> suggestions re my JavaScript version would be welcome

ok, if you really want to do this in javascript then i would suggest  
using indexOf()
and slice() to get rid of the formatting (index + comma and semicolon).
something along these lines should work:

newstr = f.readline();
if (newstr !=null){
	var komma = newstr.indexOf(",");
	newstr = newstr.slice(komma+2, newstr.lastIndexOf(";"));
	newstr = newstr.split(" ");
	for(i=0; i<newstr.length; i++)
		outlet(i, parseInt(newstr[i]));
}

hth,
volker.




More information about the javascript-dev mailing list