XML Feeds

.

[javascript-dev] String.search problem...

Anthony Palomba apalomba at austin.rr.com
Wed Jan 23 12:48:11 MST 2008


I am trying to process the lines of a file using "readline". 
I have pasted my code below. For some reason when I call
the method string "search", I get the following error...

• error: js: (null): Javascript SyntaxError: unterminated character class , line 0
• error: js: error calling function Test

For the life of me, I can not figure this one out. I know
search is a method that exists because I have called 
it before with no problems. Anyone have any ideas?



// inlets and outlets
inlets = 1;
outlets = 1;

var 	IniFile = null; 
function Test(filename)
{
	if(IniFile != null)
	{
		IniFile.close();
		IniFile = null;
	}

	IniFile = new File(filename, "read");
	if(IniFile.isopen == false)
	{
		post("FileIO Error: could not open file.
");
		return;
	}
	else
		post("file open.
");	
	
	var OutputStr = "";
	IniFile.position = 0;
	post("IniFile.position = " + IniFile.position + "
");
	post("IniFile.eof = " + IniFile.eof + "
");
	var Result = 0;
	var Line = "";
	while(IniFile.position != IniFile.eof)
	{
		Line = IniFile.readline (256);
		post("input: " + Line + "
");
		Result = Line.search("[");
		post("search done...
");
		if(Result != -1)
		{
			// remove section delimiters.
			Line.replace("[", "");
			Line.replace("]", "");
			OutputStr += Line + " ";
		}	
	}
	
	
	outlet(0, OutputStr);	
} 


More information about the javascript-dev mailing list