Subj : Compiling scripts containing more than one function To : netscape.public.mozilla.jseng From : "Bernt Johansson" Date : Sun Jun 01 2003 07:57 pm Isn't it possible to compile/execute a script containing more than one function? With only one function defined in the script it works just fine, I can call my native functions e.t.c., but when I try to define two functions in the script, the compilation fails. I have attached one of my test scripts (containing one function calling another) at the bottom of this message. I've tried a number of variants, but I just can't get it to work with two functions in the same script. The buffer I send to JS_EvaluateScript/JS_CompileScript looks like this: (...script goes here...)("just letters","111.222") I assume that the first function defined in the script takes care of the parameters "just letters" and "111.222"... Looking forward to a reply that can relieve me from my agony... /Bernt Johansson This is one of the scripts I'm trying to compile: function testFunc(str1,str2) { if (checkNumeric(str1) == true) if (checkNumeric(str2) == true) return "Both numeric"; else return "Str1 numeric"; else if (checkNumeric(str2) == true) return "Str2 numeric"; else return "None numeric"; } function checkNumeric(name) { var str = name; if ( str.length == 0 ) return false; for(var i = 0;i < str.length;i++) { var ch = str.substring(i,i+1); if (((ch < "0") || (ch > "9")) && (ch != ".")) return false; } return true; } .