Hi,
Can anyone please advise if it would be possible to implement a custom class to use for the storage of globals to allow access to the globals via the call method routine from within any script.
If it is possible would it be more efficient in speed terms for accessing and modifying an array than
load/save script
user defaults
data source
etc.
A starter example would be brilliant.
Thanks
Terry
Can you give us an example of what you’re doing? That might help us provide a better answer.
As far as I know, there’s no such mechanism. You can call handlers from the other script and pass variables or (probably) access the properties of another script (“property xyz of script somename”).
My guess is that you are stuck with a document script and a main script and need values passed between them, yes?
Typically I have an array (list) of file paths that I wnat to access from all scripts in the project not just from the application script.
I have implemented it through a load/save script with a list property but this has to be loaded by each script that uses it and if the list is modified it also has to be saved.
Use by many scripts means the script file is opened and saved regularly and if there are hundreds, getting on for a thousand paths in the list the time involved in loading and saving is noticeable.
I have tried user defaults and this is subject to the same delay suggesting the plist file is opened, read and closed regularly.
I have also considered a data source for storing the globals but have not implemented this yet. I was hoping for some feedback from someone advising if this is this is the way forward.
Finally, the custom class came to mind and I was wondering if implementing this for storing the data was possible. This would give access to the data from all scripts. There may be a speed penalty from the call method routine but I thought this may be quicker than opening and closing files as with load script or user defaults.
Any advice would be greatly appreciated.
regards
–Terry
What about using a Script Editor script, saved as an application, that has the “stay open” property checked? You would then have access to its properties through a “tell” block. That might work. Then, when you’re finished, tell the script app to quit. Here’s an example:
This is the app I created:
property myvalue : "I love grapes "
property mycount : 0
property newValue : ""
on idle
set newValue to myvalue & mycount
set mycount to mycount + 1
return 10
end idle
and this script reads from it:
set thisvalue to ""
set thisvalue to newValue of application "test app"
display dialog thisvalue
Save the app script as an application with “stay open” specified. Launch it and get it running, then run the second script from the script editor. You’ll see it picks up the information from the app.
Hi 
Very very interesting your method, Kevin 
Another way, would be to use the “pastboard” capabilities to pass from the data between several scripts…

Repost put this in the wrong thread.
Hi again,
I have been playing with a record (which is equivalent to NSDictionary).
You can read and write a record to/from a file (pList i think) using call method with
dictionaryWithContentsOfFile:
and
writeToFile:atomically:
I am thinking it must therefore be possible via an objective C custom class to
transfer the ASS record into the class as a dictionary
and
read it from the dictionary contained in the class into ASS record
This class would be available to all scripts and would therefore allow transfer of a global record
Anyone with the objective C skills to implement this please.
TIA
–Terry
I have been playing around with a Cocoa custom class.
Here is my result which seems to work with call method for setting and getting a ASS Record (cocoa NSDictionary).
Can someone with the knowledge check it over please and tell me where I have gone wrong?
Thanks
Terry
.h file
-----------------
#import <Cocoa/Cocoa.h>
@interface MYMethods: NSObject
{
}
+ (NSDictionary *)getRecord;
+ (void)setRecord:(NSDictionary *)theRecord;
@end
---------------
.m file
----------------
#import "MYMethods.h"
NSDictionary *savedRecord;
@implementation MYMethods
+ (NSDictionary *)getRecord
{
return savedRecord;
}
+ (void)setRecord:(NSDictionary *)theRecord
{
if (savedRecord)
{
[savedRecord release];
}
savedRecord = [[NSDictionary alloc] initWithDictionary:theRecord copyItems:YES];
}
@end