I have a bizarre need here, and I am unsure of it's feasibility. I can only think how I would do it using threads (To create another thread that performs a Quine function along side a thread running the script I want to Quine and execute at the same time (without manually adding alerts everywhere!!!), but javascript doesn't have that functionality, right?
I have some JavaScript which is interpreted by an application with minimal JavaScript debugging capability of it's own. My script is falling over and since it also uses some statements only understood by this application I cannot debug this within Firefox or Internet Explorer because they cannot handle these custom statements. What I am hoping I'll be able to achieve is a program that can mimic another program but also perform it's own functions.
For arguments sake say I have a script called hello.js that outputs "Hello World!" 100 times and when provided to the application it interprets this, however falls over at some point but I can't tell why, where and when because of the limited debug capability.
function main(){
for(var i=0; i<100; i++){
alert('Hello World!\n');
}
}
I then want to have a script that I can pass to the application instead that will pretend to be the script above but will also alert before each statement is executed. I could just do this:
function main(){
alert('main()')
for(var i=0; i<100; i++){
alert("alert('Hello World!\n');");
alert('Hello World!\n');
}
}
However I am sure you can see how for a long program this would be an arduous task. Do instead I want to make a program that can perform like this:
function main(){
var text = loadJSScript("C:\\Script\\Hello.js"); //Loads a text/javascript file line by line into an array
for(var i=0; i<text.length; i++){
var statement = text[i];
alert("Line Number: " + i + " Statement: " + statement); //Output the line number and statement before executing
execute(statement); //A function that executes the statement from the other file (as if a separate thread)
}
}