Sign in to follow this  
Followers 0
Realm

Array loop

6 posts in this topic

Another Noob oversight I'm sure, but I'd appreciate the help.

This is not the entire code, only a snippet of where I believe the loop is. It pulls a list of items into a listview, problem is that it loops the first column, only, infinitely.

Thanks in advance.

If Not _FileReadToArray("Test_Collection.csv",$collRecords) Then
    MsgBox(4096,"Error", " Error reading log to Array     error:" & @error)
    Exit
EndIf

While 1
    For $i=1 To UBound($collRecords)-1
        $split = StringSplit($collRecords[$i], ",", 1)
        _GUICtrlListView_AddItem($ListView1, $split[1])
        _GUICtrlListView_AddSubItem($ListView1, $i-1, $split[2], 1)
        _GUICtrlListView_AddSubItem($ListView1, $i-1, $split[3], 2)
        _GUICtrlListView_AddSubItem($ListView1, $i-1, $split[4], 3)
        _GUICtrlListView_AddSubItem($ListView1, $i-1, $split[5], 4)
        _GUICtrlListView_AddSubItem($ListView1, $i-1, $split[6], 5)
        _GUICtrlListView_AddSubItem($ListView1, $i-1, $split[7], 6)
        If @error = -1 Then ExitLoop
    Next
Wend
FileClose($file)
While 2
    Sleep(100)
WEnd

My Contributions: Unix Timestamp: Calculate Unix time, or seconds since Epoch, accounting for your local timezone and daylight savings time. RegEdit Jumper: A Small & Simple interface based on Yashied's Reg Jumper Function, for searching Hives in your registry.  

Share this post


Link to post
Share on other sites



While 1 <-- first loop (and infinate)

For <-- 2nd loop

Then ExitLoop <-- exits to the while 1 loop


010101000110100001101001011100110010000001101001011100110010000

001101101011110010010000001110011011010010110011100100001

My Android cat and mouse game
https://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek

We're gonna need another Timmy!

Share this post


Link to post
Share on other sites

While 1 <-- first loop (and infinate)

For <-- 2nd loop

Then ExitLoop <-- exits to the while 1 loop

Ouch...I forgot to take out the while loop when i changed the script....

Thanks


My Contributions: Unix Timestamp: Calculate Unix time, or seconds since Epoch, accounting for your local timezone and daylight savings time. RegEdit Jumper: A Small & Simple interface based on Yashied's Reg Jumper Function, for searching Hives in your registry.  

Share this post


Link to post
Share on other sites

While 1 <-- first loop (and infinate)

For <-- 2nd loop

Then ExitLoop <-- exits to the while 1 loop

Hmmm...then doubt 1:then can i write several Whiles?

For ex...While1 ; While2...for the same function??/

Doubt2 : If 1 = ok, Then all Whiles must have Wend?

Tkx alot.


I read ... I update ... I learn ...

Share this post


Link to post
Share on other sites

Fi0da,

You can nest as many While...WEnd loops as you want. And you can set each one as While 1 if you wish - although it might be a good idea to differentiate if you can. :)

But it is up to you to make sure you can get out of the loops once you have entered them! Play with this a bit: :(

HotKeySet("1", "Exit_1")
HotKeySet("2", "Exit_2")
HotKeySet("3", "Exit_3")

Global $fExit_1 = False, $fExit_2 = False, $fExit_3 = False

While 1

    MsgBox(0, "", "In Loop 1")

    If $fExit_1 = True Then ExitLoop

    While 2

        MsgBox(0, "", "In Loop 2")

        If $fExit_2 = True Then ExitLoop

        While 3

            MsgBox(0, "", "In Loop 3")

            If $fExit_3 = True Then ExitLoop

        WEnd

    WEnd

WEnd

Func Exit_1()
    $fExit_1 = True
EndFunc

Func Exit_2()
    $fExit_2 = True
EndFunc

Func Exit_3()
    $fExit_3 = True
EndFunc

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites

very Interesting Tkx


I read ... I update ... I learn ...

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