VBScript Example of a Scriptable Object Component

This version of the script will iterate through each available input using the For Each...Next construct.

Sub ScriptObjEvent_Start()
  'Add your code here
End Sub

Sub ScriptObjEvent_Exec(Inputs,Outputs)

Dim i
Dim dataval
i=0

'loop through Inputs collection
For each dataval in Inputs

'extract value of this particular Input
val = dataval.Value

'pop up a message box to show progress through collection, using
'only upper left element of array
If IsArray(val) Then
   MsgBox "Input: " & CStr(i) & " is an array"
Else
   MsgBox "Input: " & CStr(i) & ", Value: " & CStr(val)
End If

'just pass inputs to the outputs, incrementing
'the first element at 0,0 position by 1
If i < Outputs.Count Then
   If IsArray(val) Then
      On Error Resume Next
      vTemp = UBound(val,2)
     If Err.Number = 0 Then
         val(0,0) = val(0,0) + 1
     Else
         val(0) = val(0) + 1
     End If
   Else
     val = val + 1
  End If
   Outputs(i).Value = val
End If
i = i + 1
Next

End Sub

Sub ScriptObjEvent_Stop()
  'Add your code here
End Sub

The second version accomplishes the same task without using the For Each...Next construct:

Sub ScriptObjEvent_Start()
  'Add your code here
End Sub

Sub ScriptObjEvent_Exec(Inputs,Outputs)
Dim dataval

'use for/next construct to loop over inputs
for i=0 to Inputs.Count-1

'get the current input and its value
set dataval = Inputs(i)
val = dataval.Value

'pop up a message box to show progress through collection
MsgBox(val(0,0))

'just pass inputs on to the outputs, incrementing
'the first element by 1

if i < Outputs.Count then
  val(0,0) = val(0,0)+1
  Outputs(i).Value = val
End if
next
End Sub

Sub ScriptObjEvent_Stop()
  'Add your code here
End Sub