Jump to content

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


Go to solution Solved by Bone1970,

Recommended Posts

Posted (edited)

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
Posted

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:

  Reveal hidden contents

 

Posted

@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:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted

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

Posted (edited)

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:

  Reveal hidden contents

Updated: 22/04/2018

  • Solution
Posted

#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

Posted

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.

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