kcd-clan Posted July 3, 2006 Share Posted July 3, 2006 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() Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted July 3, 2006 Moderators Share Posted July 3, 2006 I need to count a var for a string and see how many times its in itlike how many times | is in $functionlike $function=1|2|3|4and return the number of times| is in stringI know iv seen it befor i jsut cant rember it.Look at StringSplit() 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. Link to comment Share on other sites More sharing options...
MHz Posted July 3, 2006 Share Posted July 3, 2006 Use StringReplace and read @extended $function = '1|2|3|4' StringReplace($function, '|', '') MsgBox(0, '', @extended) Link to comment Share on other sites More sharing options...
kcd-clan Posted July 3, 2006 Author Share Posted July 3, 2006 (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 July 3, 2006 by kcd-clan Visit mEMy programs made.Iul - IulG-V Console - G-V Console_RandomLetter - _RandomLetter()Saftey Kill - Saftey Killcolorzone() = colorzone() Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted July 3, 2006 Moderators Share Posted July 3, 2006 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) NextWith a request like that and an example like that, I'm sure you do need it to work. 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. Link to comment Share on other sites More sharing options...
MHz Posted July 3, 2006 Share Posted July 3, 2006 (edited) Perhaps this might do $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 July 3, 2006 by MHz Link to comment Share on other sites More sharing options...
kcd-clan Posted July 3, 2006 Author Share Posted July 3, 2006 I kinda figured that out cause i was like :/ Visit mEMy programs made.Iul - IulG-V Console - G-V Console_RandomLetter - _RandomLetter()Saftey Kill - Saftey Killcolorzone() = colorzone() Link to comment Share on other sites More sharing options...
Xenobiologist Posted July 3, 2006 Share Posted July 3, 2006 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 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now