This macro is used to embed VBScript code inside a template as part of a generation command. The result of the script is available as the ScriptResult array
.vbscript [(script-param-list)] block-input .endvbscript [(tail)]
The following parameters are available:
|
Parameter |
Description |
|---|---|
|
script-param-list |
Specifies the parameters to pass to the script through the ScriptInputArray table. Type: List of simple-template arguments separated by commas |
|
block-input |
Specifies theVBscript to run. Type: Text |
|
tail |
Appended to the output, if there is one Type: Text |
| Examples |
|---|
This simple script accepts the two words hello and world as input parameters, and returns them as a
single string with a space in between
them:.vbscript(hello, world) ScriptResult = ScriptInputArray(0) + " " + ScriptInputArray(1) .endvbscriptResult: hello world |
This script accepts an attribute code, reviews it against all the
attribute codes in the current model, and appends a
1 to it if it matches any other code:
.set_value(_code,%@1%,new)
.vbscript(%_code%)
Dim attrCode
attrCode = ScriptInputArray(0)
While (attrFound(attrCode))
attrCode = attrCode + "1"
Wend
Function attrFound(attrCode)
Dim found, attr
found = False
For Each attr in ActiveSelection.Item(0).Attributes
If attr.Code = attrCode Then
found = True
Exit For
End If
Next
For Each attr in ActiveSelection.Item(0).InheritedAttributes
If attr.Code = attrCode Then
found = True
Exit For
End If
Next
attrFound = found
End Function
ScriptResult = attrCode
.endvbscript
Note: The
active object of the current translation scope is accessed as
ActiveSelection.Item(0) (see Manipulating Models, Collections, and Objects (Scripting)).
|
For information about generation commands, see Generation Category.