Jump to content

RunAU3 error: missing Endif & error: missing until <expr>.


 Share

Go to solution Solved by Bone1970,

Recommended Posts

What i want to do is when i press a label it starts a other script (stopwatch)

The snipet thats have the error in SciTe is:

If $msg = $time1 then
        _RunAU3("Bone-stopwatch.au3")
    
        Func _RunAU3($sFilePath, $sWorkingDir = "", $iShowFlag = @SW_SHOW, $iOptFlag = 0)
            Return Run('"' & @AutoItExe & '" /AutoIt3ExecuteScript "' & $sFilePath & '"', $sWorkingDir, $iShowFlag, $iOptFlag)
        EndFunc   ;==>_RunAU3
 endif

SciTe gives me a error when i use F5 (go):error: missing Endif & error: missing until <expr>.

PS: i normaly use notepad to edit, script starts without errors when i start the script normaly.

Please can some1 help me..

Ps: SciTe gives me 9 errors in my script but its working perfectly.

If $msg = $time1 then
        _RunAU3("Bone-stopwatch.au3")
 endif

Removed the:

  Func _RunAU3($sFilePath, $sWorkingDir = "", $iShowFlag = @SW_SHOW, $iOptFlag = 0)
            Return Run('"' & @AutoItExe & '" /AutoIt3ExecuteScript "' & $sFilePath & '"', $sWorkingDir, $iShowFlag, $iOptFlag)
        EndFunc   ;==>_RunAU3

And placed it after the untill marker, fixed all my errors..

Ps: I like to thank all people on the forum for all help, i don't post alot, but I read this forum almost every day.

Edited by Bone1970
Link to comment
Share on other sites

Most of the time this error is caused by unmatches quotes.

I would check the string you create in the Run statement to see if it gives the expected result.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

@Bone1970 you are 3 and half year member of this forum.

please read:

How to post code on the forum

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 *

 

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskSchedulerIE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related:How to get reference to PDF object embeded in IE * IE on Windows 11

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

I also encourage you to check awesome @trancexx code:  * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuffOnHungApp handlerAvoid "AutoIt Error" message box in unknown errors  * HTML editor

winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2023-04-24

Link to comment
Share on other sites

If $msg = $time1 then
    _RunAU3("Bone-stopwatch.au3")
Func _RunAU3($sFilePath, $sWorkingDir = "", $iShowFlag = @SW_SHOW, $iOptFlag = 0)
        Return Run('"' & @AutoItExe & '" /AutoIt3ExecuteScript "' & $sFilePath & '"', $sWorkingDir, $iShowFlag, $iOptFlag)
EndFunc   ;==>_RunAU3   
    
endif

I have never defined a function in an if statement before. It looks wrong to me however that does not mean that it wont work. Try to define your function outside of your if statement and call your function from within the if statement.

Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html

Link to comment
Share on other sites

That looks like a function I created ages ago. No errors in my code.

Also computergroove, you need to learn about functions, as that is incorrect syntax structure.

Edited by guinness

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

  • Solution

#include <GUIConstants.au3>

AutoItSetOption("GUIResizeMode", 802)
Global $oldwidth = 114, $oldheight = 100, $ontop = 1, $time = @hour & ":" & @MIN

; create window (gui), all buttons and boxes.
$main = GUICreate("Bone-menu", 114, 100, 450, 10, $WS_POPUP + $WS_SIZEBOX); create the window
GUICtrlCreateLabel("move", 2, 2, 28, 20, $SS_CENTER, $GUI_WS_EX_PARENTDRAG) ; create the move box text "move"
    GUICtrlSetTip(-1, "move window's position") ; create the move box tooltip
    GUICtrlCreateLabel("", 0, 0, 32, 20, $SS_BLACKFRAME); create the box around move
$trans = GUICtrlCreateSlider(40, 12, 73, 18, $TBS_NOTICKS) ;
    GUICtrlSetTip(-1, "set transparency")
    GUICtrlSetLimit(-1, 255, 80)
    GUICtrlSetData(-1, 220) ; 220 is the transparency when program starts
GUICtrlCreateLabel("transparency:", 40, 0, 100, 12)
    GUICtrlSetFont(-1, 7)
$top = GUICtrlCreateCheckbox('"Always top"', 1, 25)
    GUICtrlSetState(-1, 1)
    GUICtrlSetTip(-1, "Always on top on/off")
$quit = GUICtrlCreateLabel("quit", 2, 48, 28, 20, $SS_CENTER)
    GUICtrlSetTip(-1, "exit")
    GUICtrlCreateLabel("", 0, 46, 32, 20, $SS_BLACKFRAME)
$time1 = GUICtrlCreateLabel($time, 36, 48, 33, 20, $SS_CENTER)
    GUICtrlSetTip(-1, "click to start Bone-stopwatch.au3")
    GUICtrlCreateLabel("", 35, 46, 35, 20, $SS_BLACKFRAME)
$note1 = GUICtrlCreateLabel("note's", 73, 48, 30, 20, $SS_CENTER)
    GUICtrlSetTip(-1, "click to start Bone-note.au3")
    GUICtrlCreateLabel("", 72, 46, 32, 20, $SS_BLACKFRAME)
$info = GUICtrlCreateCheckbox('"Info"', 1, 67, -1, -1, $SS_NOTIFY)
    GUICtrlSetState(-1, 0)
    GUICtrlSetTip(-1, "get color and mouse position")
; end of create window (gui), all buttons and boxes.
GUISetState()

WinSetTrans("Bone-menu", "", 220) ; set window transparency to 220
WinSetOnTop("Bone-menu", "", 1) ; set to alwways on top (1)

do
    local $time2 = @hour & ":" & @MIN
        if $time <> $time2 then ; compare old time with new time
        local $time = $time2 ; old time <> new time
    GUICtrlCreateLabel($time, 36, 48, 33, 20, $SS_CENTER); write new time
    GUICtrlCreateLabel("", 35, 46, 35, 20, $SS_BLACKFRAME); make the box around time
        endif

$msg = GUIGetMsg()

        $size = WinGetPos("Bone-menu", "")
        If $size[3] <> $oldheight then
            If $size[3] < 100 then
            WinMove("Bone-menu", "", $size[0], $size[1], $size[2], 100); smalest possible size height
        Else
            $oldheight = $size[3]
            EndIf
        EndIf

        If $size[2] <> $oldwidth then
            If $size[2] < 120 then
            WinMove("Bone-menu", "", $size[0], $size[1], 120); smalest possible size width
        Else
            $oldwidth = $size[2]
            EndIf
        EndIf

If $msg = $top then
        select
            case $ontop = 0
                WinSetOnTop("Bone-menu", "", 1)
                $ontop = 1
            case $ontop = 1
                WinSetOnTop("Bone-menu", "", 0)
                $ontop = 0
        EndSelect
EndIf

If $msg = $trans then WinSetTrans("Bone-menu", "", GUICtrlRead($trans))

If $msg = $quit then exit

If $msg = $time1 then
        _RunAU3("Bone-stopwatch.au3")
endif

If $msg = $note1 then
        _RunAU3("Bone-note.au3")
endif

If $msg = $info then ToolTip("")
    If GUICtrlRead($info) = 1 then
        $pos = mousegetpos(); get x,y position of mouse
        $color = pixelgetcolor($pos[0], $pos[1]) ; get pixel color from screen (x & y)
        ToolTip("Color " & $color & ",pos " & $pos[0] & "," & $pos[1])
EndIf

until $msg = $GUI_EVENT_CLOSE

Func _draw()
    AutoItSetOption("GUIResizeMode", 802)
EndFunc   ;==>_draw

Func _RunAU3($sFilePath, $sWorkingDir = "", $iShowFlag = @SW_SHOW, $iOptFlag = 0)
            Return Run('"' & @AutoItExe & '" /AutoIt3ExecuteScript "' & $sFilePath & '"', $sWorkingDir, $iShowFlag, $iOptFlag)
EndFunc   ;==>_RunAU3

Link to comment
Share on other sites

This is a little app i use when i play STO, just a program that tells me the time, that can call up a note-pad like program and a stop-watch.

;bone-note:
; includes
#include <GuiConstants.au3>
#include <file.au3>
global $ontop = 1
global $f_box = 1
;****************** FILE LOCATION **********
$File_loc = @ScriptDir & "\"
$File_type = "*.txt" ; filetype in list and save
;$File_type = "*.sto" ; filetype *.STO in list and save = txt file with sto ext. 
;********************************************
; create the GUI.
$win = GUICreate("Bone-notes", 350, 180, 750,10,$WS_POPUP + $WS_SIZEBOX)
; create buttons.
$btnView = GUICtrlCreateButton("View File", 0, 0, 50, 25)
GUICtrlSetTip(-1, "View selected file")
$Button1 = GUICtrlCreateButton("save", 49, 0, 40, 25)  ; save button name, place, size
GUICtrlSetTip(-1, "save selected file")
$Button2 = GUICtrlCreateButton("save as", 88, 0, 50, 25)  ; save as button name, place, size
GUICtrlSetTip(-1, "create / save as file")
$Button3 = GUICtrlCreateButton("exit", 137, 0, 40, 25)  ; exit button name, place, size
GUICtrlSetTip(-1, "exit  bone-notes")
$top = GUICtrlCreateCheckbox('Always top', 177, 0)
GUICtrlSetState(-1, 1) ; always top set to on

$filetypebox = GUICtrlCreateCheckbox('txt / sto', 255, 0)
GUICtrlSetState(-1, 1) ; ext set to txt
GUICtrlSetTip(-1, "switch file-type from .txt to .sto and back")

GUICtrlCreateLabel("", 310, 0, 40, 25, $SS_BLACKFRAME, $GUI_WS_EX_PARENTDRAG)
GUICtrlSetTip(-1, "move bone-notes window position")
$Button4 = GUICtrlCreateButton("Move", 310, 0, 40, 25)  ; save button name, place, size
GUICtrlSetTip(-1, "move bone-notes window position")

; create the left list.
$TutorItList = GUICtrlCreateList("", 10, 30, 100, 130)
; create the right edit.
$TutorItEdit = GUICtrlCreateEdit("Select a file from the list to your left.", 125, 30, 220, 145)
; set the edit colors.
GUICtrlSetBkColor(-1, 0xFFFFFF)
GUICtrlSetColor(-1, 0x000000)
; set focus to file-list.
GUICtrlSetState($TutorItList, $GUI_FOCUS)

$TutList = _FileListToArray ($File_loc, $File_type, 1); list files to an array.
    If (Not IsArray($TutList)) Or (@error = 1) Then
        MsgBox(262208, "Error", "No Files\Folders Found.   ", 5)
         EndIf
    GUICtrlSetData($TutorItList, ""); set list to empty.
    For $x = 1 To $TutList[0]; for loop to place the files in the list.
        GUICtrlSetData($TutorItList, (StringTrimRight($TutList[$x], 4)) & "|", 1); string trim the last 4 characters ( .txt )
    Next

View_tutor()

WinSetOnTop("Bone-notes", "", 1)

; show the GUI.
GUISetState()

; start the loop.
While 1
; listen for a message
    $msg = GUIGetMsg()
; using select/case for the message
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit

    Case $msg = $btnView
            View_tutor()

    case $msg = $button3
    exit

        case $msg = $filetypebox
        select
            case $f_box = 0
                $File_type = "*.txt" ; filetype in list and save
                $f_box = 1
    $TutList = _FileListToArray ($File_loc, $File_type, 1); list files to an array.
    If (Not IsArray($TutList)) Or (@error = 1) Then
    MsgBox(262208, "Tutor Error", "No Files\Folders Found.   ", 5)
        EndIf
    GUICtrlSetData($TutorItList, ""); set list to empty.
    For $x = 1 To $TutList[0]; for loop to place the files in the list.
        GUICtrlSetData($TutorItList, (StringTrimRight($TutList[$x], 4)) & "|", 1); string trim the last 4 characters ( .txt )
    Next        
        case $f_box = 1
                $File_type = "*.sto" ; filetype *.STO in list and save = txt file with sto ext. 
                $f_box = 0
                    $TutList = _FileListToArray ($File_loc, $File_type, 1); list files to an array.
    If (Not IsArray($TutList)) Or (@error = 1) Then
    MsgBox(262208, "Tutor Error", "No Files\Folders Found.   ", 5)
        EndIf
    GUICtrlSetData($TutorItList, ""); set list to empty.
    For $x = 1 To $TutList[0]; for loop to place the files in the list.
        GUICtrlSetData($TutorItList, (StringTrimRight($TutList[$x], 4)) & "|", 1); string trim the last 4 characters ( .txt )
    Next
        EndSelect
    
    
    case $msg = $top
        select
            case $ontop = 0
                WinSetOnTop("Bone-notes", "", 1)
                $ontop = 1
                
            case $ontop = 1
                WinSetOnTop("Bone-notes", "", 0)
                $ontop = 0
        EndSelect

Case $msg = $button1
            $s_text = GUICtrlRead($TutorItList)
            $n_text = StringTrimLeft($File_type, 1)
            $s_text = $File_loc & $s_text & $n_text; set the location of the file.
            filedelete($s_text) ; if you don't first delete it will apend txt to old file
            FileWrite($s_text,GUICtrlRead($TutorItEdit)); write edit-box data
            MsgBox(64,"Saved","Document was saved",5)

Case $msg = $Button2
            $s_text=FileSaveDialog("save your file...",@ScriptDir,"Text Files (*.txt)|Sto notes (*.sto)") ; save as .txt
            If $s_text="" Then
            MsgBox(64,"Cancelled","Cancelled")
            else
            filedelete($s_text)
            FileWrite($s_text,GUICtrlRead($TutorItEdit))
            MsgBox(64,"Saved","Document was saved",5)
        EndIf
    $TutList = _FileListToArray ($File_loc, $File_type, 1); list files to an array.
    If (Not IsArray($TutList)) Or (@error = 1) Then
    MsgBox(262208, "Tutor Error", "No Files\Folders Found.   ", 5)
        EndIf
    GUICtrlSetData($TutorItList, ""); set list to empty.
    For $x = 1 To $TutList[0]; for loop to place the files in the list.
        GUICtrlSetData($TutorItList, (StringTrimRight($TutList[$x], 4)) & "|", 1); string trim the last 4 characters ( .txt )
    Next

; end the selections
    EndSelect

WEnd

; Function to populate the right edit.
Func View_tutor()
    $s_text = GUICtrlRead($TutorItList); read the selected file to a variable.
    If $s_text = "" Then Return
    $n_text = StringTrimLeft($File_type, 1)
    $s_text = $File_loc & $s_text & $n_text; set the location of the file.
    Dim $Tut_text
    If Not _FileReadToArray($s_text, $Tut_text) Then; read the file to an array.
        MsgBox(4096, "Tutor Error", " Error reading log to Array     error:" & @error)
        Return
    EndIf
    GUICtrlSetData($TutorItEdit, ""); set the edit to empty.
    For $x = 1 To $Tut_text[0]; for loop to place the read file into the edit.
        GUICtrlSetData($TutorItEdit, $Tut_text[$x] & @CRLF, 1)
    Next
EndFunc

Took almost all from welcome.au3.

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