so i’m trying to avoid having to search for a file to load as a very large list each time i execute a script.
my idea is to have main.script call secondary.script to return the big list variable.
i have secondary.script set up where the list variable is a Property so that once it’s been pointed to the list’s file it won’t need to read it again. (i have checks in place if the list file is missing or modified as well).
my problem is that unless i actually open and run secondary.script it’s not updating it’s Property values and has to be pointed to the list file every time.
i need secondary.script, once it’s done it’s thing, to save itself without someone having to open and run it.
anyone have any ideas?
Hi,
post some sample code;can’t get you @all
…
i apologize for not including any code. see if this helps:
main.scpt:
set theList to run script {alias ((path to desktop as string) & "secondary.scpt")}
secondary.scpt:
property theList : ""
property theListFile : ""
property theListModificationDate : ""
on getTheList()
set theListFile to choose file with prompt "Select the list file"
tell application "Finder"
set theListModificationDate to modification date of theListFile
end tell
open for access theListFile
set theList to read theListFile using delimiter return
close access hiliteListFile
end getTheList
if theList is "" then my getTheList()
try
tell application "Finder"
set theListModificationDateTest to modification date of theListFile
end tell
if theListModificationDateTest is not equal to theListModificationDate then
open for access theListFile
set theList to read theListFile using delimiter return
close access theListFile
set theListModificationDate to theListModificationDateTest
end if
on error
my getTheList()
end try
return theList
i am looking for something between the end try and the return at the bottom of secondary.scpt that will cause the script to save itself, thereby saving the properties for the next time the script is called.
Edit,
while planning to do something simular I tested the code and it worked.
→ Saving as *.app to give the ability to store properties. start once (automatically or …) to store the properties and then call it by the mainScript with run script … the list will only be read when modified …
may be there is an easier way¿
cu
Hans
hi,
save the code as App, run the App once, then call by main.script “ didn’t test it …
property theList : ""
property theListFile : ""
property theListModificationDate : ""
on run
if theListFile is "" then
my getTheList()
else
try
tell application "Finder"
set newListModificationDateTest to modification date of theListFile
end tell
if newListModificationDateTest is not equal to theListModificationDate then
open for access theListFile
set theList to read theListFile using delimiter return
close access theListFile
set theListModificationDate to newListModificationDateTest
end if
end try
return theList
end if
end run
on getTheList()
set theListFile to choose file with prompt "Select the list file"
tell application "Finder"
set theListModificationDate to modification date of theListFile
end tell
open for access theListFile
set theList to read theListFile using delimiter return
close access theListFile
return theList
end getTheList