【发布时间】:2014-05-06 13:40:13
【问题描述】:
我不明白在为变量分配一个数字后,我是如何一直以“null”结尾的。
function evalKayScript(syn){
coms = extract(syn,"{...}");
document.write(JSON.stringify(coms));//debug
for(x in coms){
ops = extract(coms[x],"(...)");
com = null; //<-- ***com preset null***
for(y in funNames){
if(ops[1] == funNames[y]){
com = y; //<-- ***com changed to "y"***
}
}
alert(com); <-- alerts given below (first two alerts)
if(com == null){
alert("Command ((("+ops[1]+"))) Not Registered!");
return null;
}
exe = funValues[y];
inputs = execVars(ops[2]);
inputs = extract(inputs,"[...]");
for(y in inputs){
exe.replace(new RegExp("/\(\%"+y+"\%\)/gim"),inputs[y]);
}
exe.replace(new RegExp("/\(\%name\%\)/gim"),ops[0]).replace(new RegExp("/\(\%function\%\)/gim"),ops[1]);
exea = exe;
if(exe.replace(new RegExp("/\:\:\:javascript/gim"),"")! = exes){ //<-- new invalid ":" error
eval(exe);
}else{
evalKayScript(exe);
}
}
}
我不明白为什么,变量“com”变成了一个数字,然后又回到了 null... 我在自己的表单中设置了一些错误捕获,我最终得到了这些警报:
0 //<-- var com
null //<-- ***var com? this makes no sense, how does it go back to null?***
Command ((("(%name%) already exists!"))) Not Registered! //<--caused by if(com == null) This is normal.
http://jstone88.bugs3.com/kayscript/file1.html 的实时脚本,http://jstone88.bugs3.com/kayscript/kayscript.js 的 JS 文件
【问题讨论】:
-
第二次循环中似乎没有匹配的
funNames[y]。 -
com = null;将com设置为null在每次迭代中。我不清楚你的问题。 -
?但这没有意义,funNames中只有一个预设功能,肯定缺少我没有看到的东西,而@Felix King,它应该只通过一次,因为我正在进入,
{(output)(custom)([document.write(\"(%0%)\");][:::javascript])}.并且com = null;设置在为其分配新值的循环之前。 -
所以你是说
coms只包含一个属性?您对此 100% 确定吗? -
是的,@Amit Joki 给了我一个修复,我现在只有一个无效的 ":"。