Jump to content
Sign in to follow this  
pacman1176

_StringRelativeOrder

Recommended Posts

pacman1176

;
; 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!

Share this post


Link to post
Share on other sites
weaponx

You will have to require the user pass an array to the function.

Share this post


Link to post
Share on other sites
Neoflaros

Or you could just click, instead of cheating.

If we ever catch you cheating in our game, we WILL ban you.

Thanks,

Data33 - Gevalum admin.

Share this post


Link to post
Share on other sites
mikehunt114

Pac, if you can't figure it out by now, give up.


IE Dev ToolbarMSDN: InternetExplorer ObjectMSDN: HTML/DHTML Reference Guide[quote]It is surprising what a man can do when he has to, and how little most men will do when they don't have to. - Walter Linn[/quote]--------------------[font="Franklin Gothic Medium"]Post a reproducer with less than 100 lines of code.[/font]

Share this post


Link to post
Share on other sites
pacman1176

No, see I've figured it out. I just want to make it look nicer.

Share this post


Link to post
Share on other sites
mikehunt114

Terrible effort. Good luck.


IE Dev ToolbarMSDN: InternetExplorer ObjectMSDN: HTML/DHTML Reference Guide[quote]It is surprising what a man can do when he has to, and how little most men will do when they don't have to. - Walter Linn[/quote]--------------------[font="Franklin Gothic Medium"]Post a reproducer with less than 100 lines of code.[/font]

Share this post


Link to post
Share on other sites

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
Sign in to follow this  

×