Microsoft® Windows® Script Host getResource Method |
WSH Reference Version 2 |
Returns the value of a resource defined with the <resource> element.
getResource(resourceID)
Part Description resourceID A unique identifier for the resource within the script.
The <resource> element allows you to isolate strings or numbers in your Windows script file that you want to reference in your scripts. For example, resource elements typically are used to maintain strings that may be localized into other languages. You can use the getResource method in the script to extract the contents of a <resource> element.
The following code fragment defines a resource (errNonNumeric) and returns its value if the variable upperBound is not numeric.<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>