-2

This is my code

 on button873_(sender)
    set thePath to POSIX path of (choose folder with prompt "Please choose a folder to Hide")
    set otterthan to "chflags hidden "& thePath
do shell script otterthan
end

on button874_(sender)
    set otterthando to "chflags nohidden "& thePath
    do shell script otterthando
    end

But it tells me that the path is not defined, the thing i want to do is make the script remember thePath so i can use it after end.

1

1 Answer 1

3

The path is defined but you're using a local variable (if not defined globally somewhere else globally or as a property). Anyway looking at the way you named the handlers you're using AppleScriptObjC. AppleScriptObjC makes use of script objects which can have properties that can be used in all handlers within that script object.

-- AppleScriptObjC using AppleScript 2.3 syntax
script theObject
    property parent : class "NSObject"
    property thePath : missing value

    on button873:sender
        set thePath to POSIX path of (choose folder with prompt "Please choose a folder to Hide")
        set otterthan to "chflags hidden " & thePath
        do shell script otterthan
    end button873:

    on button874:sender
        set otterthando to "chflags nohidden " & thePath
        do shell script otterthando
    end button874:
end script
2
  • Could not connect the action button873: to target of class AppDelegate Jul 18, 2014 at 20:42
  • You need to convert the syntax to and older version of AppleScript. on button873_(sender) Jul 18, 2014 at 20:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.