Jump to content

For...To...Step...Next


Recommended Posts

In the For...To...Step...Next help file it states;

If stepVal or stop is a variable, its value is only read the first time the loop executes.

How can I bypass this?

He're the loop I'm trying to make;

$aMax = 0

For $idx = 0 To $aMax Step 1
    $init = "G" & $idx+1
    $date = "F" & $idx+1
    $cNext = "B" & $idx+2
            
    If _ExcelReadCell($rExcel, $init) = "JD" Or _ExcelReadCell($rExcel, $init) = "jd" Then
        $gdate = _ExcelReadCell($rExcel, $date)
        _ArrayAdd($dList, $gdate)
    EndIf
    
    ;_ArrayDisplay ($dList, "$dList") ; for debug
            
    If _ExcelReadCell($rExcel, $cNext) <> "" Then
        $aMax = $aMax + 1
    EndIf
Next

Right now, it will only loop 1 time ($idx =0). Basically, I want it to keep looping until $cNext cell is empty. And whenever it finds the initials "JD" or "jd" under the "G" column of the spreadsheet, it will grab the dates from column "F" and add it to the $dList array.

Any idea on how to bypass this?

Thank you for you time.

[font="Georgia"]Chances are, I'm wrong.[/font]HotKey trouble?Stringregexp GuideAutoIT Current Version

Link to comment
Share on other sites

$idx = 0
Do
    $init = "G" & $idx+1
    $date = "F" & $idx+1
    $cNext = "B" & $idx+2
            
    If _ExcelReadCell($rExcel, $init) = "JD" Or _ExcelReadCell($rExcel, $init) = "jd" Then
        $gdate = _ExcelReadCell($rExcel, $date)
        _ArrayAdd($dList, $gdate)
    EndIf
    $idx += 1
    ;_ArrayDisplay ($dList, "$dList") ; for debug
Until _ExcelReadCell($rExcel, $cNext) = ""

Edited by Airwolf123
Certifications: A+, Network+, Security+, Linux+, LPIC-1, MCSA | Languages: AutoIt, C, SQL, .NETBooks: AutoIt v3: Your Quick Guide - $7.99 - O'Reilly Media - September 2007-------->[u]AutoIt v3 Development - newbie to g33k[/u] - Coming Soon - Fate Publishing - Spring 2013UDF Libraries: SkypeCOM UDF Library | ADUC Computers OU Cleanup | Find PixelChecksumExamples: Skype COM Examples - Skype4COMLib Examples converted from VBS to AutoIt
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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...