Scripting Property Changes

I am trying to change the property of a script using another script.
I have a script titled “Schedule” on my desktop

I have written the following to try to change a property of “Schedule”.
The property is “named” weekend.
property weekend: {Saturday,Sunday}


set theOtherScript to load script "Paul:Desktop Folder:Schedule"

set theOtherScript's weekend to {Friday, Saturday}

display dialog (choose from list theOtherScript's weekend)

store script theOtherScript in file "Paul:Desktop Folder:Schedule" replacing yes

The result of the display dialog is a list containing “Fri” & “Sat” .
But, when I open the script “Schedule” after running the above I find that the property weekend is still the original {Saturday,Sunday}

What am I missing ?
:?:

I don’t have much experience in loading/storing scripts but I think that before storing the script, you need to set the weekend variable using the result of the dialog. Something like this might be close, but it may need tweaking (I’m running on only one cup of coffee so far this AM). :wink:

set theOtherScript to load script "Paul:Desktop Folder:Schedule"
set weekendChoices to {Friday, Saturday}
set weekendChosen to (choose from list weekendChoices)
set theOtherScript's weekend to weekendChosen
store script theOtherScript in file "Paul:Desktop Folder:Schedule" replacing yes

I just did a quick test and re-read your message. When you open the Schedule script, the value will not be changed but the changes should still be valid when the Schedule script is executed. To test this:

  1. Create, save and then run a simple script (saved as application) with the following lines:
property weekend : Sunday
display dialog weekend

It should display Sunday.

  1. Now run this from a script editor:
set theOtherScript to load script file "path:to:new_script_above"
set weekendChoices to {Friday, Saturday}
set weekendChosen to (choose from list weekendChoices)
set theOtherScript's weekend to weekendChosen
store script theOtherScript in file "path:to:new_script_above" replacing yes

Now run the first script. The dialog should reflect your choice (Friday or Saturday) even though when opened in a script editor, it says Sunday. Note: When you open a script whose properties have been changed during script execution, or by another script, the properties will be reset if the script is recompiled.

Right On Rob !

Thankx much
Paul Courtade
:slight_smile: