Page 1 of 1

How to pass a variable from a embedded applescript to Hazel

PostPosted: Thu Feb 26, 2015 6:53 am
by t_klein
Hi,

can anyone please explain me how i can pass a variable from an embedded applescript to Hazel!?

From Hazel to Applescript i use
Code: Select all
set theDate to item 1 of inputAttributes

which works perfect.

But from Applescript to Hazel i tried the following ones
Code: Select all
set outputAttributes to {"02.02.2000"}
set customAttributes to {"02.02.2000"}
set hazelOutputAttributes to {"02.02.2000"}
set hazelCustomAttributes to {"02.02.2000"}


Surely i add the name of the custom Attribute this script exports, but nothing works.

Can anyone please give me an advice.

Thanx in advance.
Thomas

Re: How to pass a variable from a embedded applescript to Ha

PostPosted: Thu Feb 26, 2015 3:28 pm
by Mr_Noodle
Search the help for "applescript". You need to return a record, not just set the variables.

Re: How to pass a variable from a embedded applescript to Ha

PostPosted: Thu Feb 26, 2015 4:30 pm
by t_klein
Hi again,

OK - understood. No more lists but records. :oops:

But it tried every keyword again, like
Code: Select all
set hazeloutputAttributes to {myNewDate:"02.02.2002"}


Can you please give me an quick and dirty example!?

Kind Regards
Thomas

Re: How to pass a variable from a embedded applescript to Ha

PostPosted: Fri Feb 27, 2015 11:49 am
by Mr_Noodle
You need to return a record as follows:
Code: Select all
    return { hazelOutputAttributes : {"02.02.2000"} }


That returns a record with the hazelOutputAttributes key and a value of a list with one item. In the UI, you need to specify the attribute which will contain that value and can be used in the rest of the rule.

Re: How to pass a variable from a embedded applescript to Ha

PostPosted: Fri Feb 27, 2015 3:09 pm
by t_klein
Mr. Noodle you are my hero!

Thank you for your great and quick support! Now it works as it should. :lol:

Kind regards
Thomas