I'm pretty new to this kind of coding, but could someone explain to me why this won't work:
jscript code:
function OnEvent_ChatWndReceiveMessage(ChatWnd, Origin, Message, MessageKind) {
//local variables
var sDetector = " ", sResponse = " "; /* sDetector is words to detect, sResponse is words to respond with */
var ofr, ofr1, ofr2, ForReading = 1; /* For reading from file */
ofr = new ActiveXObject("Scripting.FileSystemObject");
ofr1 = ofr.OpenTextFile("C:\\Program\\Messenger Plus! Live\\Scripts\\B.O.T._ Being Optimized for Troubleshooting\\text.txt", ForReading); /* Open file "Detecting Words.txt" */
ofr2 = ofr1.ReadAll(); /* Read all file contents */
ofr1.Close(); /* Close the file */
sDetector = ofr2.split("\r\n"); /* Set sDetector to every word, separated by /r/n */
ofr1 = ofr.OpenTextFile("C:\\Program\\Messenger Plus! Live\\Scripts\\B.O.T._ Being Optimized for Troubleshooting\\text.txt", ForReading); /* Open file "Responding Words.txt" */
ofr2 = ofr1.ReadAll(); /* Read all file contents */
ofr1.Close(); /* Close the file */
sResponse = ofr2.split("\r\n"); /* Set sResponse to every word, separated by \r\n */
/* 2 */
var sDetector2 = " ", sResponse2 = " "; /* sDetector is words to detect, sResponse is words to respond with */
var ofr2, ofr12, ofr22, ForReading2 = 1; /* For reading from file */
ofr2 = new ActiveXObject("Scripting.FileSystemObject");
ofr12 = ofr2.OpenTextFile("C:\\Program\\Messenger Plus! Live\\Scripts\\B.O.T._ Being Optimized for Troubleshooting\\moretext.txt", ForReading); /* Open file "Detecting Words.txt" */
ofr22 = ofr12.ReadAll(); /* Read all file contents */
ofr12.Close(); /* Close the file */
sDetector2 = ofr22.split("\r\n"); /* Set sDetector to every word, separated by /r/n */
ofr12 = ofr2.OpenTextFile("C:\\Program\\Messenger Plus! Live\\Scripts\\B.O.T._ Being Optimized for Troubleshooting\\moretext.txt", ForReading); /* Open file "Responding Words.txt" */
ofr22 = ofr12.ReadAll(); /* Read all file contents */
ofr12.Close(); /* Close the file */
sResponse = ofr2.split("\r\n"); /* Set sResponse to every word, separated by \r\n */
/* Respons */
var iCountUp = 0, iCountUpToo = 0;
if (Origin != Messenger.MyName) {
var sParts = Message.split(" ");
while(1) {
if (iCountUp == 10) {
break;
}
while(1) {
if (iCountUpToo == 10) {
break;
}
if (sParts[iCountUp] == sDetector[iCountUpToo] && sParts[iCountUp] == sDetector2[iCountUpToo]) {
ChatWnd.SendMessage(sResponse[Math.round(Math.random()%4)]);
}
iCountUpToo += 1;
}
iCountUp += 1;
}
}
What's I'm/the code is trying to do is that it will first identify a word from a file and see if that's the same as someone sends. If so it will reply. I tried to do so it would reply only if there were two words. Like instead of just "hello" it will reply on "hello mate" etc.
Thank you