IM Transformation Script 给变量赋值,不管给哪种类型的变量赋值,值都必须用"引起来
//TRUE/FALSE 类型,必须全部大写
SET VARIABLE varTrueFalse="TRUE"
IF varTrueFalse
....
END IF//integer 类型
SET VARIABLE varInt="12"
SET VARIABLE varInt=Add(varInt,"1")//string 类型
SET VARIABLE varString="abcccccccccccc "
变量赋值可以用的函数
//1. 将变量置为空
Set VARIABLE var1=Empty()//2. 判断变量是否为空
IF ISEMPTY(var1)
END IF
//3. 判断变量是否为非空
IF ISNOTEMPTY(var1)
END//4. 数值相加返回Integer
Set VARIABLE var2=Add(var1,11)//5. 减法运算返回Integer: var1-2
Set VARIABLE var2=Sub(var1,2)//6. 乘法运算(只能处理Integer): Mult(x,y)
Set VARIABLE var3=Mult(var1,var2)//7. 除法运算(只能处理Integer):Div(x,y)
Set VARIABLE var3=Div(var1,var2)//8.Date() 返回当前系统日期且格式为: "MM/DD/YYYY"
Set VARIABLE var4=Date()//9.Time() - 返回当前系统时间且格式为: "HH:MM:SS".
Set VARIABLE var4=Time()//10.Now() - 返回当前系统日期时间且格式为: "MM/DD/YYYY HH:MM:SS".
Set VARIABLE var4=Now()//11.NowReg() - 返回当前系统日期时间且格式与本机设置一样
Set VARIABLE var4=NowReg()//12.NowUtc() - 返回UTC日期时间且格式与本机设置一样
Set VARIABLE var4=NowUtc()//13.DateFormat(DateString,DatePattern,NewPattern) - 格式化的日期或时间值
//14. Count(StartNumber,StepByNumber) - 设置计数器//15. Count() - 与带参的Count函数配合使用,使StartNumber自增1.
//16. Replace(StartValue,FindValue,ReplaceValue) -字符串替换函数
Set VARIABLE var4=("I love china","china","China")//17. CountNodes() - Inserts the number of nodes that have been selected by the preceding GO TO NODES command.
//18. NodeAttr(AttributeName) - Inserts the value of the AttributeName attribute associated with the first node selected by the preceding GO TO NODES command.
//19. NodeValue() - Inserts the value of the first node selected by the preceding GO TO NODES command.
//20. NodeName() – Sets variable value to the name of the first node selected by the preceding GOTO NODES command.
以下是操作Grid的相关赋值函数
1. GetAllCells(Grid variable name, Delimeter)
- 返回以”Delimeter“做分隔符的Grid的所有值的字符串.
- 如delimeter 没给值,则默认以COMMA 做分隔符2. GetColCount(Grid variable name)
- 返回Grid的总列数3. GetRowCount(Grid variable name)
- 返回Grid 的总行数4. GetCell(Grid variable name, column, row)
- 返回Grid中指定单元格的值
以下为操作List的相关赋值函数
1. ListGetLength(List variable name)
- 返回List 长度(即Item个数).2. ListGetString(List variable name, index)
- 返回List 中index指定的Item 值(String), index 从0开始
以下为操作Bookmark的相关赋值函数
1. CopyWordsFromBookmark(Bookmark, Number of Words to copy)
- Copies the specified number of words starting at the bookmark and stores them in a named variable.2. CopyWordsFomLine(Words to skip, Words to copy, Source)
- Copies the given number of words from a variable after skipping the specified number of words and stores the result in a named variable.3. CopyBetweenBookmarks(BookmarkStart, BookmarkEnd)
- Copies everyting between the two bookmarks.4. CopyCharsFromBookmark(BookmarkStart, count)
- Copies the given number of characters,
- starting from a specified bookmark, and stores them in a named variable.
以下为操作String的相关赋值函数
1. ToUpper(variable) - 字符串转为大写
2. ToLower(variable) - 字符串转为小写
3. Replace(StartValue,FindValue,ReplaceValue)
- 字符串替换函数4. RemoveChars(variable, characters to remove)
- 从字符串中移除指定的字符
- 第2个参数说明:
ab<COMMA>l 从字符串中删除所有的a, b, I 字符.
<COMMA> 删除所有的的逗号
<SPACE> 删除所有的空格
<NEW LINE> 删除所有换行符\n
<CARRIAGE RETURN> 删除所有换行符 \r
<TAB> 删除所有\t5. StripText(variable, text string to remove)
- 删除第二个参数指定的字符串
<COMMA> - For a comma
<SPACE> - For a space
<NEW LINE> - For a \n
<CARRIAGE RETURN> - For a \r
<TAB> - For a \tNote: RemoveChars和StripText的区别,前者针对每个字符,后者针对整个字符串
RemoveChars("i love china", "china") 返回: love
var1=StripText("i love china", "china") 返回: i love5. TrimChars(variable, characters to remove)
- 从字符串中删除第2个参数指定的每一个字符.
<COMMA> - For a comma
<SPACE> - For a space
<NEW LINE> - For a \n
<CARRIAGE RETURN> - For a \r
<TAB> - For a \t
6. TrimCharsBeforeText(variable, end_text, Remove_End_Text)
- 删除第2个参数指定的字符串前面的字符并返回(包括第2个参数指定的字符串自身),
- 当Remove_End_Text=TRUE时, 即使指定的字符串位于行首页进行截取
var4=TrimCharsBeforeText("i love china","i ", FALSE) //返回: i love china
var5=TrimCharsBeforeText("i love china","i ",TRUE) //返回: love china7. TrimCharsAfterText(variable, Start_Text, Remove_Start_ext)
- 去掉第2个参数指定的字符串后面的字符并返回(包括第2个参数指定的字符串自身),
var6=TrimCharsAfterText("i love china","i ", FALSE) //返回: i
var7=TrimCharsAfterText("i love china","i ",TRUE) //返回: 空串8. TrimLeadingChars(variable, characters)
- 如字符串第一个字符开始是第二个参数指定的字符,则删除之,如第2个也是也删除, 返回剩下的字符串.
var8=TrimLeadingChars("aiai love china","i") //返回: aiai love china
var8=TrimLeadingChars("ia love china","i") //返回: a love china
var8=TrimLeadingChars("ii love china","i") //返回: love china
var8=TrimLeadingChars("aiai love china","ia")//返回: love china9. TrimTrailingChars(variable, characters)
- 从字符串最后面删除指定的字符.
var8=TrimTrailingChars("aiai love china","ia")//返回: aiai love chin10. TrimToSize(variable, size, trim from left)
- 将变量修剪到指定的大小。用户可以指定字符串是从左边还是从右边裁剪的。
-从左修剪-真或假。指示该字符串应该从左到右进行修剪还是从右到左进行修剪。
-如果设置为True,则文本将从左侧进行裁剪。
var1=TrimToSize("wwwbbbccc",2,TRUE) //返回: ww
var1=TrimToSize("wwwbbbccc",2,FALSE) //返回: cc
支持自定义的内置的VBScript函数
步骤:
1)在CommandScripts 面板定义函数
2)在Script Prcedure中填写函数体
3)调用函数