TheGeneral Posted November 27, 2008 Share Posted November 27, 2008 #RequireAdmin #include <INet.au3> #Include <String.au3> #include <EditConstants.au3> #include <array.au3> $source = _INetGetSource ( "http://forum.jogos.uol.com.br/viewtopic.php?t=1409979" ) $nicks =_StringBetween($source, "></a><b>", '</b></span><span class="postdetails">') $nick1 = _ArrayToString ( $nicks, "|", 0, 0) The $nick1 variable isn't the first value of the array, it's the whole array, how can i get only the first value? Other thing: There's anyway to keep only one value, when there're 2 or more equal values in the array? How can i get the number of rows in the array? Link to comment Share on other sites More sharing options...
GEOSoft Posted November 27, 2008 Share Posted November 27, 2008 (edited) #RequireAdmin #include <INet.au3> #Include <String.au3> #include <EditConstants.au3> #include <array.au3> $source = _INetGetSource ( "http://forum.jogos.uol.com.br/viewtopic.php?t=1409979" ) $nicks =_StringBetween($source, "></a><b>", '</b></span><span class="postdetails">') $nick1 = _ArrayToString ( $nicks, "|", 0, 0) The $nick1 variable isn't the first value of the array, it's the whole array, how can i get only the first value? Other thing: There's anyway to keep only one value, when there're 2 or more equal values in the array? How can i get the number of rows in the array?Ubound($nick) For the second question see _ArrayUnique() Edited November 27, 2008 by GEOSoft George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
TheGeneral Posted November 27, 2008 Author Share Posted November 27, 2008 I have written this: expandcollapse popup#RequireAdmin #include <INet.au3> #Include <File.au3> #Include <String.au3> #include <EditConstants.au3> #include <array.au3> $source = _INetGetSource ( "http://forum.jogos.uol.com.br/viewtopic.php?t=2112280" ) $nicks =_StringBetween($source, "></a><b>", '</b></span><span class="postdetails">') $nicks = _ArrayUnique ($nicks) _arraydisplay ($nicks) $number = UBound ($nicks) Select Case $number >=2 $nick1 = $nicks[1] Case $number >=3 $nick2 = $nicks[2] Case $number >=4 $nick3 = $nicks[3] Case $number >=5 $nick4 = $nicks[4] Case $number >=6 $nick5 = $nicks[5] Case $number >=7 $nick6 = $nicks[6] Case $number >=8 $nick7 = $nicks[7] Case $number >=9 $nick8 = $nicks[8] Case $number >=10 $nick9 = $nicks[9] Case $number >=11 $nick10 = $nicks[10] Case $number >=12 $nick11 = $nicks[11] Case $number >=13 $nick12 = $nicks[12] Case $number >= 14 $nick13 = $nicks[13] Case $number >= 15 $nick14 = $nicks[14] Case $number = 16 $nick15 = $nicks[15] EndSelect If the $number is 16, why isn't the program selecting The cases with $number >=15, 14, 13 ..? Link to comment Share on other sites More sharing options...
GEOSoft Posted November 27, 2008 Share Posted November 27, 2008 Add This after your code MsgBox(0, "TEST", $Number & @CRLF & $Nick1) What does it display? Unless you use a ContinueCase statement then it will exit the select at the first match and never get to the rest. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
PsaltyDS Posted November 28, 2008 Share Posted November 28, 2008 (edited) I have written this: CODE#RequireAdmin #include <INet.au3> #Include <File.au3> #Include <String.au3> #include <EditConstants.au3> #include <array.au3> $source = _INetGetSource ( "http://forum.jogos.uol.com.br/viewtopic.php?t=2112280" ) $nicks =_StringBetween($source, "></a><b>", '</b></span><span class="postdetails">') $nicks = _ArrayUnique ($nicks) _arraydisplay ($nicks) $number = UBound ($nicks) Select Case $number >=2 $nick1 = $nicks[1] Case $number >=3 $nick2 = $nicks[2] Case $number >=4 $nick3 = $nicks[3] Case $number >=5 $nick4 = $nicks[4] Case $number >=6 $nick5 = $nicks[5] Case $number >=7 $nick6 = $nicks[6] Case $number >=8 $nick7 = $nicks[7] Case $number >=9 $nick8 = $nicks[8] Case $number >=10 $nick9 = $nicks[9] Case $number >=11 $nick10 = $nicks[10] Case $number >=12 $nick11 = $nicks[11] Case $number >=13 $nick12 = $nicks[12] Case $number >= 14 $nick13 = $nicks[13] Case $number >= 15 $nick14 = $nicks[14] Case $number = 16 $nick15 = $nicks[15] EndSelectIf the $number is 16, why isn't the program selecting The cases with $number >=15, 14, 13 ..? Select/EndSelect and Switch/EndSwitch will only execute ONE case. Once a matching case is found and the code under that case is executed, the script jumps to the EndSelect or EndSwitch statement. Also, sequentially named variables like '$nick1' through '$nick15' should just be assembled as a single array. This does what I think you were shooting for: ; ...<snip> Global $avNick[16] $nicks =_StringBetween($source, "></a><b>", '</b></span><span class="postdetails">') $nicks = _ArrayUnique ($nicks) _arraydisplay ($nicks) $number = UBound ($nicks) If $number > 2 Then For $n = 2 To 16 If $number > $n Then $avNick[$n - 1] = $nicks[$n - 1] Next EndIf Edited November 28, 2008 by PsaltyDS Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
TheGeneral Posted November 28, 2008 Author Share Posted November 28, 2008 (edited) Select/EndSelect and Switch/EndSwitch will only execute ONE case. Once a matching case is found and the code under that case is executed, the script jumps to the EndSelect or EndSwitch statement. Also, sequentially named variables like '$nick1' through '$nick15' should just be assembled as a single array. This does what I think you were shooting for: ; ...<snip> Global $avNick[16] $nicks =_StringBetween($source, "></a><b>", '</b></span><span class="postdetails">') $nicks = _ArrayUnique ($nicks) _arraydisplay ($nicks) $number = UBound ($nicks) If $number > 2 Then For $n = 2 To 16 If $number > $n Then $avNick[$n - 1] = $nicks[$n - 1] Next EndIf I solved that: Func TopicoNicks($var2) Global $avNick[16] $source = _INetGetSource($var2) $nicks = _StringBetween($source, "></a><b>", '</b></span><span class="postdetails">') $nicks = _ArrayUnique($nicks) $number = UBound($nicks) If $number > 2 Then For $n = 2 To 16 If $number >= $n Then GuiListAdd($nicks[$n - 1]) Next EndIf EndFunc ;==>TopicoNicks Edited November 28, 2008 by TheGeneral Link to comment Share on other sites More sharing options...
BrettF Posted November 28, 2008 Share Posted November 28, 2008 Select/EndSelect and Switch/EndSwitch will only execute ONE case. Once a matching case is found and the code under that case is executed, the script jumps to the EndSelect or EndSwitch statement. Also, sequentially named variables like '$nick1' through '$nick15' should just be assembled as a single array. This does what I think you were shooting for: ; ...<snip> Global $avNick[16] $nicks =_StringBetween($source, "></a><b>", '</b></span><span class="postdetails">') $nicks = _ArrayUnique ($nicks) _arraydisplay ($nicks) $number = UBound ($nicks) If $number > 2 Then For $n = 2 To 16 If $number > $n Then $avNick[$n - 1] = $nicks[$n - 1] Next EndIf But if we use ContinueCase can't we change that? expandcollapse popup#RequireAdmin #include <INet.au3> #Include <File.au3> #Include <String.au3> #include <EditConstants.au3> #include <array.au3> $nicks = "1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20" $nicks = StringSplit ($nicks, "|") $number = 10 Select Case $number = 16 $nick15 = $nicks[15] ContinueCase Case $number >= 15 $nick14 = $nicks[14] ContinueCase Case $number >= 14 $nick13 = $nicks[13] ContinueCase Case $number >=13 $nick12 = $nicks[12] ContinueCase Case $number >=12 $nick11 = $nicks[11] ContinueCase Case $number >=11 $nick10 = $nicks[10] ContinueCase Case $number >=10 $nick9 = $nicks[9] ContinueCase Case $number >=9 $nick8 = $nicks[8] ContinueCase Case $number >=8 $nick7 = $nicks[7] ContinueCase Case $number >=7 $nick6 = $nicks[6] ContinueCase Case $number >=6 $nick5 = $nicks[5] ContinueCase Case $number >=5 $nick4 = $nicks[4] ContinueCase Case $number >=4 $nick3 = $nicks[3] ContinueCase Case $number >=3 $nick2 = $nicks[2] ContinueCase Case $number >=2 $nick1 = $nicks[1] ContinueCase EndSelect $output = "" For $i = 1 to 15 $output &= "Value of nick" & $i & " = " & Eval ("nick" & $i) & @CRLF Next MsgBox (0, "", $output) Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
PsaltyDS Posted November 28, 2008 Share Posted November 28, 2008 I solved that: Func TopicoNicks($var2) Global $avNick[16] $source = _INetGetSource($var2) $nicks = _StringBetween($source, "></a><b>", '</b></span><span class="postdetails">') $nicks = _ArrayUnique($nicks) $number = UBound($nicks) If $number > 2 Then For $n = 2 To 16 If $number >= $n Then GuiListAdd($nicks[$n - 1]) Next EndIf EndFunc ;==>TopicoNicks Great. I would recommend moving the Global declaration of $avNick outside the function. Declaring globals inside a function might work, but will trigger warnings on syntax check and is generally considered bad practice in AutoIt. But if we use ContinueCase can't we change that? ; ...<snip> Select Case $number = 16 $nick15 = $nicks[15] ContinueCase Case $number >= 15 $nick14 = $nicks[14] ContinueCase ; ...<snip> Case $number >=2 $nick1 = $nicks[1] ContinueCase EndSelect That might work, but it's ugly and requires a long repeatitive block of code. Any time you find yourself repeating the same code over and over its time to look for a better way. The short For/Next loops to do the same thing are much more efficient. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law 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