Carl1959 Posted July 10, 2023 Posted July 10, 2023 (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 July 10, 2023 by Carl1959 Add tags
Nine Posted July 10, 2023 Posted July 10, 2023 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. “They did not know it was impossible, so they did it” ― Mark Twain Reveal hidden contents Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy
mistersquirrle Posted July 10, 2023 Posted July 10, 2023 You mainly just need to move your Function declarations outside of your For...Next loop, which should handle your primary issue. expandcollapse popup#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.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now