InstallScript脚本语言基本知识(一)
1.自定义函数
1 //函数的声明:prototype 返回值 函数名(形参类型1,...) 2 export prototype STRING GetPreDir(STRING); 3 4 //函数体 5 function STRING GetPreDir(szDir) 6 //定义内部使用的变量 7 number iLen,i; 8 STRING szSubStr; 9 begin 10 szSubStr = szDir; 11 i =1; 12 iLen = StrLength(szDir); 13 if(iLen>5) then 14 while(i<iLen) 15 if(szDir[iLen -i] = "\\") then 16 StrSub(szSubStr,szDir,0,iLen -i); 17 i = iLen; 18 endif; 19 i++; 20 endwhile; 21 //szDir =szSubStr; 22 endif; 23 24 return szSubStr; 25 end;
2. 基本数据类型
3.基本语句
//if-then 结构 if(条件表达式) then 语句 endif; //if-then-else 结构 if(条件表达式) then 语句1 else 语句2 endif; //elseif 结构 if(条件表达式1) then 语句1 elseif(条件表达式2) then 语句2 elseif(条件表达式3) then 语句3 ... endif; //if和goto结构 //一旦szSrc为空字符串时,反复执行Name标号所在位置的语句。 Name: AskText("Company name:","",szSrc); ... if(szSrc = "") goto Name;
switch(表达式) case 常量1:语句1 case 常量2:语句2 ... case 常量n:语句n default:语句n+1 endswitch; while(表达式) 语句 endwhile; repeat 语句 until(表达式);
//X是循环变量,A是循环变量初值,B是循环变量终值,C是循环变量的增量,如果省略step C,默认C=1 for X=A to B step C 语句 endfor; //to也可以改为downto,如下。C就变成减去的值。 for X=A dowmto B step C 语句 endfor;