用于隔離不應(yīng)硬編碼到腳本中的文本數(shù)據(jù)或數(shù)字?jǐn)?shù)據(jù)。
<resource id="resourceID"> text or number </resource>
<resource> 元素允許您在 Windows 腳本 (.wsf) 文件中隔離要在腳本中引用的字符串或數(shù)字。例如,資源元素通常用于維護(hù)可本地化為其他語言的字符串。
要獲取資源的值,就要調(diào)用 getResource 方法,將它傳遞給要使用的資源 ID。
將使用元素中的所有內(nèi)容,包括空白區(qū)域(制表符、新行等)。
下面的代碼定義資源 (errNonNumeric),如果變量 upperBound 不是數(shù)字,則返回資源的值。
<resource id="errNonNumeric">
Non-numeric value passed
</resource>
<script language="VBScript">
<![CDATA[
Function getRandomNumber(upperBound)
If IsNumeric(upperBound) Then
getRandomNumber = CInt(upperBound * Rnd + 1)
Else
getRandomNumber=getResource("errNonNumeric")
End If
End Function
]]>
</script>
<runtime> 元素 | <named> 元素 | <description> 元素 | <example> 元素 | <object> 元素 | <package> 元素 | getResource 方法