Incomplete Expression Errors

Issue #7 resolved
Ryan Jarvis created an issue

The following script has errors found but compiles and runs fine in the script editor.

Errors:

Incomplete expression (at line 6)
Incomplete expression (at line 11)
Incomplete expression (at line 24)
Syntax error
Application Services
'+', '-', '.', <built in class identifier plural>, <script property declaration>, <var declaration list>, Apr, April, Aug, August, BUILT_IN_PROPERTY, CUBIC_VOL, CURRENT_APP, CURRENT_APPLICATION, DIGITS, Dec, December, FILE_SPECIFICATION, Feb, February, Fri, Friday, INTERNATIONAL_TEXT, Jan, January, Jul, July, Jun, June, LOCATION_SPECIFIER, MISSING_VALUE, Mar, March, May, Mon, Monday, NLS, Nov, November, Oct, October, QUOTED_FORM, RGB_COLOR, SCRIPTING_ADDITIONS, SQUARE_AREA, STYLED_CLIPBOARD_TEXT, STYLED_TEXT, Sat, Saturday, Sep and ... expected, got '
        ' (at line 11)
<application handler definition>, <assignment statement>, <expression>, <script property declaration>, <var declaration list>, COMMENT, NLS, RAW_CODE, considering, continue, exit, if, ignoring, on, return, script, tell, to, try, use, using or with expected, got 'else' (at line 13)
')', <compare expression>, <filter reference>, <handler parameter label>, <multiplicative expression>, <object reference expression> or returning expected, got '1' (at line 14)
of expected, got 'if' (at line 15)
'+', '-', '.', <built in class identifier plural>, <script property declaration>, <var declaration list>, Apr, April, Aug, August, BUILT_IN_PROPERTY, CUBIC_VOL, CURRENT_APP, CURRENT_APPLICATION, DIGITS, Dec, December, FILE_SPECIFICATION, Feb, February, Fri, Friday, INTERNATIONAL_TEXT, Jan, January, Jul, July, Jun, June, LOCATION_SPECIFIER, MISSING_VALUE, Mar, March, May, Mon, Monday, NLS, Nov, November, Oct, October, QUOTED_FORM, RGB_COLOR, SCRIPTING_ADDITIONS, SQUARE_AREA, STYLED_CLIPBOARD_TEXT, STYLED_TEXT, Sat, Saturday, Sep and ... expected, got '
        ' (at line 24)
<application handler definition>, <assignment statement>, <expression>, <script property declaration>, <var declaration list>, COMMENT, NLS, RAW_CODE, considering, continue, exit, if, ignoring, on, return, script, tell, to, try, use, using or with expected, got 'else' (at line 26)
')', <compare expression>, <filter reference>, <handler parameter label>, <multiplicative expression>, <object reference expression> or returning expected, got '1' (at line 27)
of expected, got 'if' (at line 28)
of expected, got 'tell' (at line 43)
--- Choose an application to watch
--- Choose an application to open when this application is activated
--- Can also be used for watching/launching documents/files/scripts (ostensibly. hasn't been tested)
--- NOTE: sometimes does not work with applications that have multiple names

tell application "Finder"


    set wapp_name to choose file with prompt "What application should I watch?" default location "/Applications"
    tell application "Finder" to set {dispName, nameExt, isHidden} to the {displayed name, name extension, extension hidden} of wapp_name
    if isHidden or nameExt is equal to "" then
        dispName
    else
        (characters 1 through (-2 - (count of nameExt)) of dispName) as text
    end if
    set baseName to result
    set fwapp_name to baseName

    delay 0.4

    set oapp_name to choose file with prompt "What application should open when " & fwapp_name & " is activated?"
    set poapp_name to POSIX path of oapp_name
    tell application "Finder" to set {odispName, onameExt, oisHidden} to the {displayed name, name extension, extension hidden} of oapp_name
    if oisHidden or onameExt is equal to "" then
        odispName
    else
        (characters 1 through (-2 - (count of onameExt)) of odispName) as text
    end if
    set obaseName to result
    set foapp_name to obaseName

    repeat
        tell application "System Events"
            set process_list to the name of every process whose visible is true
            if process_list contains fwapp_name then
                open oapp_name
                exit repeat
            else
                delay 10
            end if
        end tell
    end repeat
end tell

--- http://www.scriptogr.am/unforswearing
--- http://www.github.com/unforswearing
--- notes@theforeverarrow.com

Comments (4)

  1. Ryan Jarvis reporter

    Perhaps a more succint version of this

    set isHidden to true
    
    set dispName to "Test Script"
    
    if isHidden then
        dispName
    else
        -- This line seems to cause the issue
        (characters 1 through (-2 - (count of nameExt)) of dispName) as text
    end if
    
  2. Log in to comment