Jump to content

For loop error


Recommended Posts

What does _GUICtrlListView_GetItemCount() return?

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

  • Moderators

Reinhardt1julian,

The problem is obvious - in line 35829 you are not furgling the qualopper. :o

;....

Seriously, what on earth do you expect us to say when faced with a small syntactically incorrect snippet like that? Post the whole code and then you might stand a chance of getting a sensible answer. ;)

m23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

I agree with Melba23, I reckon there is more to this than just that code above.

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

Reinhardt1julian,

The problem is obvious - in line 35829 you are not furgling the qualopper. :o

;....

Seriously, what on earth do you expect us to say when faced with a small syntactically incorrect snippet like that? Post the whole code and then you might stand a chance of getting a sensible answer. ;)

m23

 

I know that it isn't that much. But my whole code is 1400 lines and the for loop alone is 150 lines. And

Link to comment
Share on other sites

the for loop alone is 150 lines.

Then it's probably further inside that For loop which is the issue. Why not work backwards and learn the art of debugging.

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

Works fine for me.  Added your snippet into the base help file example

#include <GUIConstantsEx.au3>
#include <GuiListView.au3>

$Debug_LV = False ; Check ClassName being passed to ListView functions, set to True and use a handle to another control to see it work

_Main()

Func _Main()
    Local $hListView

    GUICreate("ListView Get Item Count", 400, 300)
    $hListView = GUICtrlCreateListView("col1|col2|col3", 2, 2, 394, 268)
    GUISetState()

    GUICtrlCreateListViewItem("line1|data1|more1", $hListView)
    GUICtrlCreateListViewItem("line2|data2|more2", $hListView)
    GUICtrlCreateListViewItem("line3|data3|more3", $hListView)
    GUICtrlCreateListViewItem("line4|data4|more4", $hListView)
    GUICtrlCreateListViewItem("line5|data5|more5", $hListView)

;~     MsgBox(4160, "Information", "Item Count: " & _GUICtrlListView_GetItemCount($hListView))

    ; Loop until user exits
    For $x = 1 to _GUICtrlListView_GetItemCount($hListView)
        MsgBox(0,"",$x&" of "&_GUICtrlListView_GetItemCount($hListView))
        ;some stuff here
    Next

    GUIDelete()
EndFunc   ;==>_Main

I bet, somewhere in your loop, you are setting x=x-1, or x-=1, so you never get above 1...or you have nested loops, both using the same variable (easy mistake in large loops).

example of that:

#include <GUIConstantsEx.au3>
#include <GuiListView.au3>

$Debug_LV = False ; Check ClassName being passed to ListView functions, set to True and use a handle to another control to see it work

_Main()

Func _Main()
    Local $hListView

    GUICreate("ListView Get Item Count", 400, 300)
    $hListView = GUICtrlCreateListView("col1|col2|col3", 2, 2, 394, 268)
    GUISetState()

    GUICtrlCreateListViewItem("line1|data1|more1", $hListView)
    GUICtrlCreateListViewItem("line2|data2|more2", $hListView)
    GUICtrlCreateListViewItem("line3|data3|more3", $hListView)
    GUICtrlCreateListViewItem("line4|data4|more4", $hListView)
    GUICtrlCreateListViewItem("line5|data5|more5", $hListView)

;~     MsgBox(4160, "Information", "Item Count: " & _GUICtrlListView_GetItemCount($hListView))

    ; Loop until user exits
;~  For $x = 1 to _GUICtrlListView_GetItemCount($hListView)
;~      MsgBox(0,"",$x&" of "&_GUICtrlListView_GetItemCount($hListView))
;~      ;some stuff here
;~  Next

    ; Loop until user exits
    For $x = 1 to _GUICtrlListView_GetItemCount($hListView)
        If MsgBox(1,"",$x&" will always be one...cancel to exit.") > 1 Then Exit
        $x-=1
        ;some stuff here
    Next

    GUIDelete()
EndFunc   ;==>_Main

If none of those help, then post your code :)...or at least code that reproduces it.

Edited by jdelaney
IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Link to comment
Share on other sites

If you guys fins any problems in this code, tell me, but I will try to find it, too :D

;this won't run, because it needs a file
For $x = 1 to _GUICtrlListView_GetItemCount($List1data)
        $line = FileReadLine($tempFile, $x)
        MsgBox(0,"",$x&" of "&_GUICtrlListView_GetItemCount($List1data))
        If $line = "0" Then
            If _checkmess(_GUICtrlListView_GetItemTextString($List1data, $x-1),$x-1,$tag3) AND StringInStr($used,"'"&$x-1&"'") = 0 Then
                Global $zero
                $zero[$zeronum] = $x-1
                $zeronum = $zeronum + 1
            Else
            EndIf
        ElseIf $line = "1" Then
            If _checkmess(_GUICtrlListView_GetItemTextString($List1data, $x-1),$x-1,$tag3) AND StringInStr($used,"'"&$x-1&"'") = 0 Then
                Global $one
                $one[$onenum] = $x-1
                $onenum = $onenum + 1
            Else
            EndIf
        ElseIf $line = "2" Then
            If _checkmess(_GUICtrlListView_GetItemTextString($List1data, $x-1),$x-1,$tag3) AND StringInStr($used,"'"&$x-1&"'") = 0 Then
                Global $two
                $two[$twonum] = $x-1
                $twonum = $twonum + 1
            Else
            EndIf
        ElseIf $line = "3" Then
            If _checkmess(_GUICtrlListView_GetItemTextString($List1data, $x-1),$x-1,$tag3) AND StringInStr($used,"'"&$x-1&"'") = 0 Then
                Global $three
                $three[$threenum] = $x-1
                $threenum = $threenum + 1
            Else
            EndIf
        ElseIf $line = "4" Then
            If _checkmess(_GUICtrlListView_GetItemTextString($List1data, $x-1),$x-1,$tag3)AND StringInStr($used,"'"&$x-1&"'") = 0 Then
                Global $four
                $four[$fournum] = $x-1
                $fournum = $fournum + 1
            Else
            EndIf
        ElseIf $line = "5" Then
            If _checkmess(_GUICtrlListView_GetItemTextString($List1data, $x-1),$x-1,$tag3) AND StringInStr($used,"'"&$x-1&"'") = 0 Then
                Global $five
                $five[$fivenum] = $x-1
                $fivenum = $fivenum + 1
            Else
            EndIf
        ElseIf $line = "6" Then
            If _checkmess(_GUICtrlListView_GetItemTextString($List1data, $x-1),$x-1,$tag3) AND StringInStr($used,"'"&$x-1&"'") = 0 Then
                Global $six
                $six[$sixnum] = $x-1
                $sixnum = $sixnum + 1
            Else
            EndIf
        ElseIf $line = "7" Then
            If _checkmess(_GUICtrlListView_GetItemTextString($List1data, $x-1),$x-1,$tag3) AND StringInStr($used,"'"&$x-1&"'") = 0 Then
                Global $seven
                $seven[$sevennum] = $x-1
                $sevennum = $sevennum + 1
            Else
            EndIf
        ElseIf $line = "8" Then
            If _checkmess(_GUICtrlListView_GetItemTextString($List1data, $x-1),$x-1,$tag3) AND StringInStr($used,"'"&$x-1&"'") = 0 Then
                Global $eight
                $eight[$eightnum] = $x-1
                $eightnum = $eightnum + 1
            Else
            EndIf
        ElseIf $line = "9" Then
            If _checkmess(_GUICtrlListView_GetItemTextString($List1data, $x-1),$x-1,$tag3) AND StringInStr($used,"'"&$x-1&"'") = 0 Then
                Global $nine
                $nine[$ninenum] = $x-1
                $ninenum = $ninenum + 1
            Else
            EndIf
        Else
        EndIf
        ;MsgBox(0,"",$zeronum&" - "&$onenum&" - "&$twonum&" - "&$threenum&" - "&$fournum&" - "&$fivenum&" - "&$sixnum&" - "&$sevennum&" - "&$eightnum&" - "&$ninenum)
        While 1
            If $zeronum > 0 Then
                If $zeronum = 1 Then
                    Return $zero[0]
                Else
                    Return $zero[Random(0,$zeronum-1)]
                EndIf
            ElseIf $onenum > 0 Then
                If $onenum = 1 Then
                    Return $one[0]
                Else
                    Return $one[Random(0,$onenum-1)]
                EndIf
            ElseIf $twonum > 0 Then
                If $twonum = 1 Then
                    Return $two[0]
                Else
                    Return $two[Random(0,$twonum-1)]
                EndIf
            ElseIf $threenum > 0 Then
                If $threenum = 1 Then
                    Return $three[0]
                Else
                    Return $three[Random(0,$threenum-1)]
                EndIf
            ElseIf $fournum > 0 Then
                If $fournum = 1 Then
                    Return $four[0]
                Else
                    Return $four[Random(0,$fournum-1)]
                EndIf
            ElseIf $fivenum > 0 Then
                If $fivenum = 1 Then
                    Return $five[0]
                Else
                    Return $five[Random(0,$fivenum-1)]
                EndIf
            ElseIf $sixnum > 0 Then
                If $sixnum = 1 Then
                    Return $six[0]
                Else
                    Return $six[Random(0,$sixnum-1)]
                EndIf
            ElseIf $sevennum > 0 Then
                If $sevennum = 1 Then
                    Return $seven[0]
                Else
                    Return $seven[Random(0,$sevennum-1)]
                EndIf
            ElseIf $eightnum > 0 Then
                If $eightnum = 1 Then
                    Return $eight[0]
                Else
                    Return $eight[Random(0,$eightnum-1)]
                EndIf
            ElseIf $ninenum > 0 Then
                If $ninenum = 1 Then
                    Return $nine[0]
                Else
                    Return $nine[Random(0,$ninenum-1)]
                EndIf
            Else
                Return False
            EndIf
        WEnd
    Next
Link to comment
Share on other sites

  • Moderators

Reinhardt1julian,

Do you have another loop inside that one which also uses $x as its variable? Perhaps you are resetting the count inside the loop to a high ennough value that when you get to the final Next you fall through rather than looping back. :huh:

M23

Edit: "Post" button pressed before the code above appeared. :)

Edited by Melba23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Reinhardt1julian,

Do you have another loop inside that one which also uses $x as its variable? Perhaps you are resetting the count inside the loop to a high ennough value that when you get to the final Next you fall through rather than looping back. :huh:

M23

 

Doesn't seem like it. I postet the whole loop. And i can't find any other $x in the3 code except in the for loop.

Link to comment
Share on other sites

The only way out of your while loop is "Return" so I guess this is inside a function.  If you are returning, then you are ending the function completely, both the For loop and the While loop.

EDIT: In other words, there is no way for the script to ever make it to "Next".

Edited by DW1
Link to comment
Share on other sites

The only way out of your while loop is "Return" so I guess this is inside a function.  If you are returning, then you are ending the function completely, both the For loop and the While loop.

EDIT: In other words, there is no way for the script to ever make it to "Next".

 

Oh my god, thank you! That was such a stupid mistake to make :/

Link to comment
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
 Share

×
×
  • Create New...