Sign in to follow this  
Followers 0
kcd-clan

I need to count a string how many times $i is in it

8 posts in this topic

I need to count a var for a string and see how many times its in it

like how many times | is in $function

like $function=1|2|3|4

and return the number of times| is in string

I know iv seen it befor i jsut cant rember it.


Visit mEMy programs made.Iul - IulG-V Console - G-V Console_RandomLetter - _RandomLetter()Saftey Kill - Saftey Killcolorzone() = colorzone()

Share this post


Link to post
Share on other sites



I need to count a var for a string and see how many times its in it

like how many times | is in $function

like $function=1|2|3|4

and return the number of times| is in string

I know iv seen it befor i jsut cant rember it.

Look at StringSplit()

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

I need this to work?

and thanks mhz you achtoly help.

$list=StringSplit($list,'|')
    $lista=0
    $listb=0
    $i=0
    For $i=0 To 50 Step 1
    $listb=$listb+24
    If $list[$i] ="" Then ExitLoop
$a[1]=GUICtrlCreateLabel($list[$i],$lista,$listb,200,200)
    Next
Edited by kcd-clan

Visit mEMy programs made.Iul - IulG-V Console - G-V Console_RandomLetter - _RandomLetter()Saftey Kill - Saftey Killcolorzone() = colorzone()

Share this post


Link to post
Share on other sites

I need this to work?

$list=StringSplit($list,'|')
    $lista=0
    $listb=0
    $i=0
    For $i=0 To 50 Step 1
    $listb=$listb+24
    If $list[$i] ="" Then ExitLoop
$a[1]=GUICtrlCreateLabel($list[$i],$lista,$listb,200,200)
    Next
With a request like that and an example like that, I'm sure you do need it to work.

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Perhaps this might do :D

$list=StringSplit($list,'|')
    If Not @error Then
        Global $a[ $list[0] + 1]
        $lista = 0
        $listb = 0
        For $i = 1 To $list[0]
            $listb=$listb + 24
            $a[$i]=GUICtrlCreateLabel($list[$i], $lista, $listb, 200, 200)
        Next
    EndIf

Edit:

Changed For count to start from 1 rather then 0.

Edited by MHz

Share this post


Link to post
Share on other sites

Hi,

MsgBox(0,'Count',_StringCount('1|2|3|4', '|'))

Func _StringCount($sString, $vDelimeter, $iEntireString = 1)
    If Not StringInStr($sString, $vDelimeter) Then
        SetError(1)
        Return 0
    EndIf
    Return UBound(StringSplit($sString, $vDelimeter, $iEntireString)) - 2
EndFunc

So long,

Mega


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

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  
Followers 0