Jump to content

Recommended Posts

Posted

;
; Function Name:    _StringRelativeOrder()
; Description:      Finds relative occurance of a given string with respect to given strings.

;Func _StringRelativeOrder($str, $searchString, $str0, $str1, $str2, $str3, $str4, $str5, $cS = 0) ;$cS = caseSensitive
    Dim $val[6]
    $searchval = StringInStr($str, $searchString, $cS)

    $val[0] = StringInStr($str, $str0, $cS))
    $val[1] = StringInStr($str, $str1, $cS))
    $val[2] = StringInStr($str, $str2, $cS))
    $val[3] = StringInStr($str, $str3, $cS))
    $val[4] = StringInStr($str, $str4, $cS))
    $val[5] = StringInStr($str, $str5, $cS))
    $result = 0
    For $i = 0 To 5;Ubound($val) - 1
        If $searchval > $val[$i] Then
            $result = $result + 1
        EndIf
    Next
    Return $result
EndFunc  ;==>_StringRelativeOrder

The purpose is finding the relative position of a certain string with respect to other strings, designed to handle randomness. For example, if you had:

$searchStat = "Str"
$Clip = "[b]Wis[/b] and some [b]Dex [/b]random text [b]Str [/b]possibly inbetween [b]Vit [/b]your relative strings [b]Mana Knw[/b]"

$result = _StringRelativeOrder($Clip, $searchStat, "Str", "Dex", "Vit", "Mana", "Knw", "Wis", 1)

then $result would equal 3 in this case.

What I'm asking though, is for some tweaking. Certain functions like StringFormat can handle a variable amount of parameters, how could you write a function to handle as well as tell how many parameters are being used.

StringFormat ( "format control", var1 [, ... var32] )

It also would be rather convenient to put as much as possible into a UBound for statement (like the StringinStr). I haven't figured a way to do this.

Also maybe someone's got a better name for the function or a better description. Perhaps a better way of calculating the result all together. Learn me!

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...