jiaoben

所属分类:数学计算
开发工具:Java
文件大小:59KB
下载次数:5
上传日期:2009-07-13 14:13:36
上 传 者hary123
说明:  一个完整的脚本演示,包含源码,以及演示包,想学的去看看吧
(Demonstration of a complete script, including source code, as well as the presentation package, I would like to go and see to learn)

文件列表:
demo\SMain.java (1500, 2008-03-03)
demo\demoScript.bat (24, 2008-03-03)
demo\config\key.txt (159, 2008-03-01)
demo\config\function.txt (84, 2008-03-01)
demo\image\icon.png (933, 2008-03-01)
demo\ScriptEditor.exe (82862, 2008-03-03)
demo\demoScript.jar (12256, 2008-03-03)
demo\demo.sct (100, 2008-03-03)
demo\demo.s (197, 2008-03-03)
demo\config (0, 2008-03-03)
demo\image (0, 2008-03-03)
demo (0, 2008-03-03)

小型脚本语言演示程序 可为JAVA程序开发提供完善的脚本支持,解释器包只有19K,也可用做手机游戏开发 优点:功能全,运行速度快,与接口方式提供本地函数支持,无任何扩展限制 不足:为了运行速度的提高,脚本需要使用编辑器进行编译后才能使用 演示程序使用方法: 用脚本编辑器编辑脚本后用demoScript.bat运行脚本 脚本格式如下: Function 函数名(在演示中默认为main) 程序内容,可调用本地函数或脚本函数,同时也支持把某一个.s文件做为库函数 endFunction 脚本中的关键字: Function 函数名 if 条件表达式 如 a==b a!=b ab a>b||b>a a>=b&&(b=0 print v[c] c=c-1 loop endFunction //提供本地方法的例子: 在类中引用implements lScriptFunction 并增加下例函数 public lScriptValue localFunction(lScript s,lScriptMemory arg0, String arg1) { //如增加一个本地的max功能 if ( arg1.equals("max") { int v = arg0.pop().getInteger() ; int v1 = arg0.pop().getInteger() ; return lScriptValue.createValue((v>v1)?v:v1) ; } } //JAVA程序调用脚本的方法 lScript script = new lScript() ; script.addScript(file) ; script.doLoadFunction("函数名") ; script.addFunctionListener(this) ; // 增加本地函数的监听 //script.setDebugMode(true) ; // 可以打开debug开关,看运行状态 while(script.runScript()==false) ; // runScript()返回true,运行结速 //在JAVA中中断脚本 script.doInterrupt() ; //恢复中断 script.doResume() ; 比如你的脚本调用了本地的showDialog,但showDialog并不是马上返回,要等有操作才返回 这时你就可以调用doInterrupt() ;中断 当完成时 如果有返回值,调用lScriptMemroy.push(lScriptValue.createValue(返回值) 再调用doResume() ; //在JAVA中调用有参数的函数 如调用max(int:v,int:v1) lScriptMemory.push(lScriptValue.createValue(v1)) ; lScriptMemory.push(lScriptValue.createValue(v)) ; script.doLoadFunction("max") ; lScriptValue ret = lScriptMemory.pop().getInteger() ; 如果有更多需要了解,请联系 QQ:188492208

近期下载者

相关文件


收藏者