Jump to content

Problems using Next inside If Then


Recommended Posts

This gets compile errors at the marked Next statement. I just cannot see what I am doing wrong?

#RequireAdmin

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_UseUpx=y
#AutoIt3Wrapper_Run_Au3Stripper=y
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****



; Include libraries and System settings
#include <IE.au3>
#include <MsgBoxConstants.au3>
#include <ScreenCapture.au3>
#include <File.au3>
#include <FileConstants.au3>
#include <Excel.au3>
AutoItSetOption('MouseCoordMode', 0) ; set mouse to use current window for coodinates rather than the whole screen
; ______________________________________________________________________________________________________________________

; Global Variable definitions
Global $oIE5
Global $s_Test_Request                ; Test Request
Global $s_Test_Sequence                ; Test Sequence
Global $s_Test_Sequence_Folder        ; Test Sequence Folder name
Global $s_Test_Sequence_File_Name    ; Test Sequence file being processed
Global $s_AQA_Path                    ; Full Path to the AQA Testing Folder
Global $s_TC_Id                        ; Test Case ID (From TestRail)
Global $s_TC_Component                ; ARMS Component
Global $s_TC_Function                ; ARMS Function
Global $s_TC_Feature                ; ARMS Feature
Global $s_TC_TestCase                ; Arms Test Case


; ______________________________________________________________________________________________________________________

; *****  Processing starts here  *****

; Get Test Requent and Test Sequence Number from user

; ++++++++++ Call Startup Function here

; Hard code startup parametere for testing and development
    $s_Test_Request = "9999"
    $s_Test_Sequence = "001"
    $s_AQA_Path = "K:\ATT\TechnicalServicesGroup\SpecialAccess\TestEngineering\ARMS_QA\Tests_In_Progress"
    $s_Test_Sequence_Folder = $s_AQA_Path & "\QA_Testing_9999_For_Development_&_Testing_Only\Sequence_9999_001"


; Get list of files in the Test Sequence folder
    Local $hTS_Files = FileFindFirstFile($s_Test_Sequence_Folder & "\ARMS_AQA_TS*.xls")

    ; Check for no-files found
    If $hTS_Files = -1 Then
        MsgBox($MB_SYSTEMMODAL, "ARMS AQA System", "Error: No Test Sequence files found in Test Sequence Folder:" & @CRLF & $s_Test_Sequence_Folder)
        Exit
    EndIf

    ;Process Each Test Sequence file
    ; Get file names and process each one at a time
    Local $iResult = 0
    While 1
        $s_Test_Sequence_File_Name = FileFindNextFile($hTS_Files)
        If @error then ExitLoop

        ;*** Process each file***
        MsgBox(0, "AQA Testing", $s_Test_Sequence_File_Name)
        Call ("Process_TS_File")

    WEnd

Exit ; For testing

; ______________________________________________________________________________________________________________________

Func Process_TS_File()

; Process Next Test Sequence File

    Local $oAppl = _Excel_Open()

    ; Open Test Sequence File
    Local $oTS_WB_Handle = _Excel_BookOpen($oAppl, $s_Test_Sequence_Folder & "\" & $s_Test_Sequence_File_Name)
    If @error Then
        MsgBox($MB_SYSTEMMODAL, "ARMS AQA System", "Error: Test Sequence Excel WorkBook" & @CRLF & "Got Open Error:  " & @error & @CRLF & "File Name:  " & $s_Test_Sequence_File_Name)
        Exit
    EndIf

    ; Get Cell Contents for each row
    For $i = 2 to 1000

        ; Is Test Active?
        Local $sActive = _Excel_RangeRead($oTS_WB_Handle, Default,"B" & $i)
        If @error Then
            MsgBox($MB_SYSTEMMODAL, "ARMS AQA System", "Error: Cell B" & $i & " could not be read"& @CRLF & "Got Read Error:  " & @error)
            Exit
        EndIf
        MsgBox (0, "ARMS ADA Testing", "Cell B" & $i & ":  " & $sActive)

        If $sActive = "y" or $sActive = "Y" Then
            Next ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
        EndIf

        ; Get Test Case ID
        $s_TC_I = _Excel_RangeRead($oTS_WB_Handle, Default,"A" & $i)
        If @error Then
            MsgBox($MB_SYSTEMMODAL, "ARMS AQA System", "Error: Cell A" & $i & " could not be read"& @CRLF & "Got Read Error:  " & @error)
            Exit
        EndIf
        MsgBox (0, "ARMS ADA Testing", "Cell A" & $i & ":  " & $s_TC_I)
    Next

    ; Close Test Sequence File
    _Excel_BookClose($oTS_WB_Handle)

EndFunc

 

 

Edited by Melba23
Added code tags
Link to comment
Share on other sites

  • Moderators

MWichter,

Welcome to the AutoIt forum.

But please pay attention to where you post - the "Dev Chat" section where you started this thread is not for general support questions.  I have moved it for you, but would ask you to be more careful in future.

As to the problem, try using ContinueLoop at that point.

M23

P.S. When you post code please use Code tags - see here how to do it.  Then you get a scrolling box and syntax colouring as you can see above now I have added the tags.

 

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

  • Moderators

MWichter,

Glad I could help.

I wish the "For" description included this

ContinueLoop is mentioned as "Related" on the For..To..Next..Step page in the Help file - personally I think that is adequate.

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

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...