Sign in to follow this  
Followers 0
MoxFirefox

For loop forcing Exit

4 posts in this topic

#1 ·  Posted

Im using a simple for loop and when one loop is done it exits the program. I have no clue why it happends. Attached is the code.

 

$rowSize = UBound($fromArray, 1)
    for $row = 2 to $rowSize
        Local $type = $fromArray[$row][13]
        _DebugOut("Row: "&$row & " ,Type: "&$type & @LF)
        if($type == "Spoor") Then
            Local $geoCode = $fromArray[$row][4]
            Local $km = $fromArray[$row][8]
            Local $kmVan = $fromArray[$row][9]
            Local $kmTot = $fromArray[$row][10]
            ;_DebugOut("     Geocode: "&$geoCode & @LF)
            ;_DebugOut("     KM: "&$km & @LF)
            ;_DebugOut("     KM-van: "&$kmVan & @LF)
            ;_DebugOut("     KM-tot: "&$kmTot & @LF)

            $loc = _searchArray($km, $kmVan, $kmTot, $geoCode)
            _DebugOut("    Loc: " & $loc)
        EndIf
    Next

EndFunc


Func _searchArray($km = 0,$kmVan = 0,$kmTot = 0,$geocode = 0)
    $searchSize = UBound($searchArray, 1)
    for $i = 1 to $searchSize
        Local $searchGeo = " "
        $searchGeo = $searchArray[$i][5]

        if($searchGeo = $geocode) Then
            _DebugOut("          Found same geo!")
        EndIf
    Next
    _DebugOut("For done!")
    ;Return "Out";

EndFunc

Can anyone know why it does it. The output of the debug is:

Begin Zoek...

Row: 2 ,Type: Spoor

          Found same geo!
          Found same geo!
          Found same geo!
          Found same geo!
          Found same geo!
>>>>>> Please close the "Report Log Window" to exit <<<<<<<

 

Share this post


Link to post
Share on other sites



#2 ·  Posted

maybe try:

$rowSize = UBound($fromArray, 1)
For $row = 2 To $rowSize - 1
    Local $type = $fromArray[$row][13]
    _DebugOut("Row: " & $row & " ,Type: " & $type & @LF)
    If ($type == "Spoor") Then
        Local $geoCode = $fromArray[$row][4]
        Local $km = $fromArray[$row][8]
        Local $kmVan = $fromArray[$row][9]
        Local $kmTot = $fromArray[$row][10]
        ;_DebugOut("     Geocode: "&$geoCode & @LF)
        ;_DebugOut("     KM: "&$km & @LF)
        ;_DebugOut("     KM-van: "&$kmVan & @LF)
        ;_DebugOut("     KM-tot: "&$kmTot & @LF)

        $loc = _searchArray($km, $kmVan, $kmTot, $geoCode)
        _DebugOut("    Loc: " & $loc)
    EndIf
Next

;EndFunc  

Func _searchArray($km = 0, $kmVan = 0, $kmTot = 0, $geoCode = 0)
    $searchSize = UBound($searchArray, 1)
    For $i = 1 To $searchSize - 1
        Local $searchGeo = " "
        $searchGeo = $searchArray[$i][5]

        If ($searchGeo = $geoCode) Then
            _DebugOut("          Found same geo!")
        EndIf
    Next
    _DebugOut("For done!")
    ;Return "Out";

EndFunc   ;==>_searchArray

 


Regards,
 

Share this post


Link to post
Share on other sites

#3 ·  Posted

2 minutes ago, Trong said:

maybe try:

$rowSize = UBound($fromArray, 1)
For $row = 2 To $rowSize - 1
    Local $type = $fromArray[$row][13]
    _DebugOut("Row: " & $row & " ,Type: " & $type & @LF)
    If ($type == "Spoor") Then
        Local $geoCode = $fromArray[$row][4]
        Local $km = $fromArray[$row][8]
        Local $kmVan = $fromArray[$row][9]
        Local $kmTot = $fromArray[$row][10]
        ;_DebugOut("     Geocode: "&$geoCode & @LF)
        ;_DebugOut("     KM: "&$km & @LF)
        ;_DebugOut("     KM-van: "&$kmVan & @LF)
        ;_DebugOut("     KM-tot: "&$kmTot & @LF)

        $loc = _searchArray($km, $kmVan, $kmTot, $geoCode)
        _DebugOut("    Loc: " & $loc)
    EndIf
Next

;EndFunc  

Func _searchArray($km = 0, $kmVan = 0, $kmTot = 0, $geoCode = 0)
    $searchSize = UBound($searchArray, 1)
    For $i = 1 To $searchSize - 1
        Local $searchGeo = " "
        $searchGeo = $searchArray[$i][5]

        If ($searchGeo = $geoCode) Then
            _DebugOut("          Found same geo!")
        EndIf
    Next
    _DebugOut("For done!")
    ;Return "Out";

EndFunc   ;==>_searchArray

 

Thanks, But im not sure what you changed, you removed the EndFunc and added the last line. But I followed that and then it cant find the Func _searchArray()

Share this post


Link to post
Share on other sites

#4 ·  Posted

You post not fully script!
You see anything else?

$rowSize = UBound($fromArray, 1)
For $row = 2 To $rowSize - 1
    Local $type = $fromArray[$row][13]
    _DebugOut("Row: " & $row & " ,Type: " & $type & @LF)
    If ($type == "Spoor") Then
        Local $geoCode = $fromArray[$row][4]
        Local $km = $fromArray[$row][8]
        Local $kmVan = $fromArray[$row][9]
        Local $kmTot = $fromArray[$row][10]
        ;_DebugOut("     Geocode: "&$geoCode & @LF)
        ;_DebugOut("     KM: "&$km & @LF)
        ;_DebugOut("     KM-van: "&$kmVan & @LF)
        ;_DebugOut("     KM-tot: "&$kmTot & @LF)

        $loc = _searchArray($km, $kmVan, $kmTot, $geoCode)
        _DebugOut("    Loc: " & $loc)
    EndIf
Next

EndFunc  

Func _searchArray($km = 0, $kmVan = 0, $kmTot = 0, $geoCode = 0)
    $searchSize = UBound($searchArray, 1)
    For $i = 1 To $searchSize - 1
        Local $searchGeo = " "
        $searchGeo = $searchArray[$i][5]

        If ($searchGeo = $geoCode) Then
            _DebugOut("          Found same geo!")
        EndIf
    Next
    _DebugOut("For done!")
    ;Return "Out";

EndFunc

 


Regards,
 

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