Windows Script Components  

getResource Function

Gets the value of a resource defined with the <resource> element.

value = getResource(resourceID)

Values

resourceID
A unique identifier for the resource within the script component.

Remarks

The <resource> element allows you to isolate strings or numbers in your script component that you want to intermingle with script in your script component. For example, resource elements are typically used to maintain strings that might be localized into another language. You can use the getResource function in the script component's script to extract the contents of a <resource> element.

Example

The following script component fragment defines a resource (called errNonNumeric) and how to use it in script.

Note   A CDATA section is required to make the script in the <script> element opaque. For details, see Script Component Files and XML Conformance.
<public>
   <method name="random" internalName="getRandomNumber"/>
</public>
<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>

See Also

Referencing Other Components