共用方式為


<resource> Element (Windows Script Host)

Isolates textual or numeric data that should not be hard-coded into a script.

                      <resource id="resourceID">
   text or number
</resource>

Arguments

  • resourceID
    Unique identifier for the resource within the script.

Remarks

The <resource> element allows you to isolate strings or numbers in your Windows Script (.wsf) file that you want to reference in your scripts. For example, resource elements are typically used to maintain strings that may be localized into other languages.

To get the value of a resource, call the getResource method, passing it the ID of the resource you want to use.

Everything within the elements gets used including white space (tabs, new lines, etc.).

Example

The following code 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>

See Also

Reference

<runtime> Element (Windows Script Host)

<named> Element

<description> Element (Windows Script Host)

<example> Element

<object> Element (Windows Script Host)

<package> Element (Windows Script Host)

getResource Method