Jump to content

Recommended Posts

Posted (edited)

Basically a new user here. I’ve only used AutoIt once before, and that was long ago and many versions ago. Apparently, the GOTO statement is gone from AutoIt. Therefore using a loop; or trying to. I seem to be having a problem with my FOR/NEXT loop. Basically the same error if I use DO/UNTIL or WHILE/WEND.

The error I get is “Func GetPatient()   Error: FOR statement has no matching NEXT statement.”

Well, I do have a matching NEXT statement at the bottom of the script. I can’t see any reason why this won’t work. Any help appreciated.

Script starts on next line.

[autoit]

#include <MsgBoxConstants.au3>
#include <Array.au3>
#include <String.au3>
Global $sText
Global $sChart
Global $sDirectory
Global $aArray

RunWait ("C:\Program Files (x86)\DEXIS\Patient Administration.exe", "c:\Program Files (x86)\DEXIS")

;WinActivate ("DEXIS Administration")

WinMove ( "DEXIS Administration", "", 70, 20, 700, 500 )
Local $i = 0
For $i = 1 to 10
MouseMove ( 370, 145)
MouseClick ( 'LEFT', 370, 145, 2 )
Sleep (5000)
GetPatient()
Func GetPatient()
        ; Retrieve the window title of the active window.
        $sText = WinGetTitle("[ACTIVE]")
        ; Display the window title.
        ;MsgBox($MB_SYSTEMMODAL, "", $sText)
EndFunc   ;==>GetPatient
Chart()
Func Chart()
        ; Create an array of all the values between "(" and ")".
        $aArray = _StringBetween($sText, "(", ")")
        ; Display the results in _ArrayDisplay.
        ;_ArrayDisplay($aArray, "Default Search")
EndFunc   ;==>Chart
$sDirectory = ("C:\Users\Administrator.DAVIDSERVER\Desktop\Images\" & $aArray [0])
;MsgBox($MB_SYSTEMMODAL, "", $sDirectory)
DirCreate ($sDirectory)
Send("{a}")
Sleep (1000)
MouseClick ( 'LEFT', 282, 219, 2 )
Sleep (1000)
MouseClick ( 'LEFT', 516, 45, 1 )
Sleep (1000)
MouseClick ( 'LEFT', 331, 61, 1 )
Sleep (1000)
MouseClick ( 'LEFT', 900, 638, 1 )
Sleep (1000)
MouseClick ( 'LEFT', 588, 45, 1 )
Sleep (1000)
Send($sDirectory)
MouseClick ( 'LEFT', 460, 177, 1 )
Sleep (500)
MouseClick ( 'LEFT', 771, 610, 1 )
Sleep (10000)
WinClose ( "DEXIS" )
Next

[/autoit]

Edited by Carl1959
Add tags
Posted

That's a badly written script.  Maybe you should learn the basics of programming.  You are including inside the "main" script a function which is not allowed.

Also when you post code, please use the method described in the link.

Posted

You mainly just need to move your Function declarations outside of your For...Next loop, which should handle your primary issue.

#include <MsgBoxConstants.au3>
#include <Array.au3>
#include <String.au3>
Global $sText
Global $sChart
Global $sDirectory
Global $aArray

RunWait("C:\Program Files (x86)\DEXIS\Patient Administration.exe", "c:\Program Files (x86)\DEXIS")

;WinActivate ("DEXIS Administration")

WinMove("DEXIS Administration", "", 70, 20, 700, 500)
Local $i = 0
For $i = 1 To 10
    MouseMove(370, 145)
    MouseClick('LEFT', 370, 145, 2)
    Sleep(5000)
    GetPatient()
    Chart()
    $sDirectory = ("C:\Users\Administrator.DAVIDSERVER\Desktop\Images\" & $aArray[0])
    ;MsgBox($MB_SYSTEMMODAL, "", $sDirectory)
    DirCreate($sDirectory)
    Send("{a}")
    Sleep(1000)
    MouseClick('LEFT', 282, 219, 2)
    Sleep(1000)
    MouseClick('LEFT', 516, 45, 1)
    Sleep(1000)
    MouseClick('LEFT', 331, 61, 1)
    Sleep(1000)
    MouseClick('LEFT', 900, 638, 1)
    Sleep(1000)
    MouseClick('LEFT', 588, 45, 1)
    Sleep(1000)
    Send($sDirectory)
    MouseClick('LEFT', 460, 177, 1)
    Sleep(500)
    MouseClick('LEFT', 771, 610, 1)
    Sleep(10000)
    WinClose("DEXIS")
Next

Func Chart()
    ; Create an array of all the values between "(" and ")".
    $aArray = _StringBetween($sText, "(", ")")
    ; Display the results in _ArrayDisplay.
    ;_ArrayDisplay($aArray, "Default Search")
EndFunc   ;==>Chart
Func GetPatient()
    ; Retrieve the window title of the active window.
    $sText = WinGetTitle("[ACTIVE]")
    ; Display the window title.
    ;MsgBox($MB_SYSTEMMODAL, "", $sText)
EndFunc   ;==>GetPatient

The problem is that you can't declare a function in a loop, and why would you want to? At that point, just don't use a function, and include what's inside the function in the loop instead.

We ought not to misbehave, but we should look as though we could.

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
  • Recently Browsing   0 members

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