VBScript range function

A VBScript equivalent of PHP’s range


Function range(low,high,step)

    Dim matrix
    Dim inival, endval, plus
    Dim walker : If len(step) > 0 Then walker = step Else walker = 1
    Dim chars : chars = false

    If isNumeric(low) and isNumeric(high) Then
        inival = low
        endval = high
    ElseIf Not isNumeric(low) and Not isNumeric(high) Then
        chars  = true
        inival = Asc(low)
        endval = Asc(high)
    Else
        inival = [?](isNumeric(low),low,0)
        endval = [?](isNumeric(high),high,0)
    End If

    plus = true
    If inival > endval Then plus = false

    If plus Then
        Do While inival <= endval
            [] matrix, [?](chars,Chr(inival),inival)
            inival = inival + walker
        Loop
    Else
        Do While inival >= endval
            [] matrix, [?](chars,Chr(inival),inival)
            inival = inival - walker
        Loop
    End If

    range = matrix

End Function


Please also note that php.vbs offers community built functions and goes by the McDonald’s Theory. We’ll put online functions that are far from perfect, in the hopes to spark better contributions. Do you have one? Then please just:

Other PHP functions in the array extension