Skip to content
Permalink
Browse files

Add 3 SSC functions for VB6 Interaction functions (completes the set …

…of 4 VB6 Interaction functions).

* SSC.Choose(Index, ParamArray Choices):
  - chooses the element from the provided parameters in Choices
  - returns Null if out of range (Index is 1 to parameter count)
  [custom-built as calling VB6 version is impossible]
* SSC.IIf(Expression, TruePart, FalsePart):
  - chooses either TruePart or FalsePart based on whether Expression is True.
  [added by Pyro, not me! - I changed comment to use VB6 URL instead]
* SSC.Partition(Number, Start, End, Interval) As String:
  - returns a string representing the range where a number resides ("start:end") in a repeating interval defined by Start To End Step Interval
  - apparently useful for database queries
  [if end <= start or interval <= 0 then returns Null]
* SSC.Switch(ParamArray ExpressionPartPairs):
  - returns first even Part argument where the odd Expression argument before it is True.
  - returns Null if no True odd arguments or if odd number of arguments and last argument is the True expression.
  [custom-built as calling VB6 version is impossible]
  • Loading branch information...
nmbook committed Apr 10, 2016
1 parent f55614e commit 9dbbc2ce36530af2f20852ec321294ed97f6024d
Showing with 37 additions and 1 deletion.
  1. +37 −1 trunk/clsScriptSupportClass.cls
@@ -1570,13 +1570,49 @@ Public Function GetCurrentServerIP()
End If
End Function

'// CHOOSE
'// Returns the chosen value based on the given index.
'// see: https://msdn.microsoft.com/en-us/library/aa262690(v=vs.60).aspx
Public Function Choose(ByVal aIndex As Single, ParamArray pChoice() As Variant) As Variant
Choose = Null
If aIndex > 0 And aIndex <= UBound(pChoice) Then
Choose = pChoice(aIndex - 1)
End If
End Function

'// IIF
'// Returns a different value based on if a statement is true or false.
'// see: https://msdn.microsoft.com/en-us/library/27ydhh0d(v=vs.90).aspx
'// see: https://msdn.microsoft.com/en-us/library/aa445024(v=vs.60).aspx
Public Function IIf(ByVal bExpression As Boolean, ByVal vTruePart As Variant, ByVal vFalsePart As Variant) As Variant
IIf = Interaction.IIf(bExpression, vTruePart, vFalsePart)
End Function

'// PARTITION
'// Returns the range that the specified Number appears in in the given interval defined by Start, Stop, and Interval.
'// see: https://msdn.microsoft.com/en-us/library/aa445092(v=vs.60).aspx
Public Function Partition(ByVal aNumber As Long, ByVal aStart As Long, ByVal aStop As Long, ByVal aInterval As Long) As String
Partition = Null
If aInterval > 0 And aStop > aStart Then
Partition = Interaction.Partition(aNumber, aStart, aStop, aInterval)
End If
End Function

'// SWITCH
'// Returns the first even item in the parameter list after the odd expression that is true.
'// There must be an even number of arguments.
'// see: https://msdn.microsoft.com/en-us/library/aa263378(v=vs.60).aspx
Public Function Switch(ParamArray pVarExpr() As Variant) As Variant
Dim i As Long

Switch = Null
For i = 0 To UBound(pVarExpr) - 1 Step 2
If pVarExpr(i) Then
Switch = pVarExpr(i + 1)
Exit Function
End If
Next i
End Function

'Class_Terminate doesn't run when a UI form is created via a script. I made this sub so the bot's Unload sub can explicitly _
call the code within Class_Terminate to kill all the objects. - FrOzeN
Public Sub Dispose()

0 comments on commit 9dbbc2c

Please sign in to comment.
You can’t perform that action at this time.