edit/amend an applescript app using another applescript app

Hi all,
I have a script that has some large Property lists in it, occasionally I may need to add to these property lists. I would like to be able to amend these lists using a less complex script that anybody can use, so that they don’t have to trail through all the code to change or add something, is it possible to amend an applescript app using another? Any suggestions would be welcome!
Thanks

Hi,

what’s about using user defaults

do shell script "defaults write myPrefs testvalue Hello" 

creates a property list file myPrefs.plist in ~/Library/Preferences with a key testvalue and its string value Hello

Note: if the file is not in ~/Library/Preferences, you must use the whole path (without the .plist extension)

to read (and display) a value, use this for example

display dialog (do shell script "defaults read myPrefs testvalue")

You can also do this in an application bundle

set myDefaults to POSIX path of ((path to me) & "Contents/Resources/myPrefs")
do shell script "defaults write " & quoted form of myDefaults & " testvalue Hello"

read the man page of defaults for further options

Hi Stefan,
Thanks for your reply, my property list looks like this

property pub_code_List : {"aba3", "abig", "abus", "acap", "acne", "acpc", "agil", "alto", "auda", "bdjo", "bipl", "bsal", "bsrt", "bsss", "caup", "cclv", "cfrd", "chcg", "chcs", "chdm", "chot", "chww", "ciab", "cja4", "cjar", "cjat", "cjaw", "cjca", "cjce", "cjcf", "cjcp", "cjhs", "cjib", "cjip", "cjmm", "cjnc", "cjnf", "cjou", "cjre", "cjsa", "cjsd", "cjsk", "cjsm", "cjtb", "cjtr", "cldr", "cmot", "cmrp", "cmsp", "cmtr", "cmus", "comc", "comp", "cosc", "crop", "crss", "csss", "ctaw", "ctsh", "cwee", "demo", "doct", "ecne", "egas", "egaz", "egbc", "egca", "egcm", "egcr", "egdp", "egdr", "egem", "egff", "egfi", "egin", "egir", "egld", "egne", "egnw", "egof", "egpl", "egrf", "egrl", "egrt", "egsc", "egsw", "egwm", "egys", "eirr", "elaw", "eorw", "epfm", "etab", "euad", "eucc", "euel", "euka", "euks", "eupn", "euro", "euwd", "ewbg", "ewcd", "ewdb", "ewdw", "ewed", "ewee", "ewem", "ewle", "ewns", "ewps", "fbik", "fcar", "ffrd", "fiar", "fidn", "fint", "fipd", "futm", "fwas", "fwaw", "fwbe", "fwbu", "fwcs", "fwcu", "fwde", "fwdi", "fwdu", "fweb", "fwee", "fwff", "fwfl", "fwfs", "fwgr", "fwgs", "fwhe", "fwhs", "fwip", "fwlp", "fwpr", "fwrs", "fwsm", "fwss", "fwsu", "fwts", "fwtt", "gtec", "guit", "hacn", "hdoc", "hjbe", "hjby", "hjco", "hjdi", "hjfu", "hjfw", "hjgo", "hjgp", "hjhy", "hjin", "hjlk", "hjlo", "hjmg", "hjou", "hjrd", "hjrp", "hjsi", "hjss", "hjtg", "hjwc", "hjwd", "hjwe", "hjxt", "hrom", "hva4", "hvns", "icba", "icbg", "icbm", "imco", "inpr", "irer", "irlb", "irpi", "ledi", "lene", "mach", "mcso", "miav", "micr", "mihs", "mimo", "mipt", "mism", "mist", "mits", "mmag", "mrhb", "mrsg", "mrvt", "mrwa", "mrwk", "mryp", "mtra", "mtvf", "mvpt", "mycl", "natu", "nele", "nsgd", "nsoz", "nsuk", "nsus", "nwor", "oche", "ochr", "oosg", "opop", "opti", "pabb", "pchk", "pmjo", "pnur", "pran", "prds", "pria", "prir", "prod", "prwk", "ptab", "ptim", "ptno", "ptod", "ptrd", "ptre", "pwbs", "pwor", "raco", "redl", "rgin", "rgmt", "rgra", "rhyt", "rnew", "rnpr", "rtex", "sehb", "seng", "supp", "tesm", "tess", "test", "tesw", "tfed", "tgit", "tgsp", "thes", "tote", "tovx", "trdr", "trkg", "trng", "ttes", "twaa", "twab", "twag", "twah", "twbb", "twbt", "twcb", "twch", "twcr", "twcs", "twct", "twct", "twct", "twcy", "twda", "twdk", "twdn", "twdu", "twec", "twek", "tweu", "twgc", "twgl", "twhf", "twhk", "twic", "twie", "twin", "twis", "twki", "twki", "twla", "twlt", "twlu", "twma", "twme", "twmo", "twoz", "twpa", "twre", "twsa", "twsp", "twtc", "twte", "twth", "twti", "twtk", "twtr", "twtw", "twua", "twuk", "twus", "twwa", "upda", "uwee", "uwet", "wman", "zero", "hjbr", "ch36", "ewds", "cmld"}

so how do I separate each list item using your

do shell script "defaults write myPrefs testvalue Hello"

I tried using the same code {“aba3”, “abig”, “abus”} an so on, but obviously shell commands for separating list items are different to applescript.

:lol:

I assumed the property list like this

property p1 : "1"
property p2 : "2"

well, using one property containing a list can be handled with a script object

set thePath to (path to scripts folder as Unicode text) & "pubcode.scpt"
script pub_code
	property pub_code_List : {"aba3", "abig", "abus", "acap", "acne", "acpc", "agil", "alto", "auda", "bdjo", "bipl", "bsal", "bsrt", "bsss", "caup", "cclv", "cfrd", "chcg", "chcs", "chdm", "chot", "chww", "ciab", "cja4", "cjar", "cjat", "cjaw", "cjca", "cjce", "cjcf", "cjcp", "cjhs", "cjib", "cjip", "cjmm", "cjnc", "cjnf", "cjou", "cjre", "cjsa", "cjsd", "cjsk", "cjsm", "cjtb", "cjtr", "cldr", "cmot", "cmrp", "cmsp", "cmtr", "cmus", "comc", "comp", "cosc", "crop", "crss", "csss", "ctaw", "ctsh", "cwee", "demo", "doct", "ecne", "egas", "egaz", "egbc", "egca", "egcm", "egcr", "egdp", "egdr", "egem", "egff", "egfi", "egin", "egir", "egld", "egne", "egnw", "egof", "egpl", "egrf", "egrl", "egrt", "egsc", "egsw", "egwm", "egys", "eirr", "elaw", "eorw", "epfm", "etab", "euad", "eucc", "euel", "euka", "euks", "eupn", "euro", "euwd", "ewbg", "ewcd", "ewdb", "ewdw", "ewed", "ewee", "ewem", "ewle", "ewns", "ewps", "fbik", "fcar", "ffrd", "fiar", "fidn", "fint", "fipd", "futm", "fwas", "fwaw", "fwbe", "fwbu", "fwcs", "fwcu", "fwde", "fwdi", "fwdu", "fweb", "fwee", "fwff", "fwfl", "fwfs", "fwgr", "fwgs", "fwhe", "fwhs", "fwip", "fwlp", "fwpr", "fwrs", "fwsm", "fwss", "fwsu", "fwts", "fwtt", "gtec", "guit", "hacn", "hdoc", "hjbe", "hjby", "hjco", "hjdi", "hjfu", "hjfw", "hjgo", "hjgp", "hjhy", "hjin", "hjlk", "hjlo", "hjmg", "hjou", "hjrd", "hjrp", "hjsi", "hjss", "hjtg", "hjwc", "hjwd", "hjwe", "hjxt", "hrom", "hva4", "hvns", "icba", "icbg", "icbm", "imco", "inpr", "irer", "irlb", "irpi", "ledi", "lene", "mach", "mcso", "miav", "micr", "mihs", "mimo", "mipt", "mism", "mist", "mits", "mmag", "mrhb", "mrsg", "mrvt", "mrwa", "mrwk", "mryp", "mtra", "mtvf", "mvpt", "mycl", "natu", "nele", "nsgd", "nsoz", "nsuk", "nsus", "nwor", "oche", "ochr", "oosg", "opop", "opti", "pabb", "pchk", "pmjo", "pnur", "pran", "prds", "pria", "prir", "prod", "prwk", "ptab", "ptim", "ptno", "ptod", "ptrd", "ptre", "pwbs", "pwor", "raco", "redl", "rgin", "rgmt", "rgra", "rhyt", "rnew", "rnpr", "rtex", "sehb", "seng", "supp", "tesm", "tess", "test", "tesw", "tfed", "tgit", "tgsp", "thes", "tote", "tovx", "trdr", "trkg", "trng", "ttes", "twaa", "twab", "twag", "twah", "twbb", "twbt", "twcb", "twch", "twcr", "twcs", "twct", "twct", "twct", "twcy", "twda", "twdk", "twdn", "twdu", "twec", "twek", "tweu", "twgc", "twgl", "twhf", "twhk", "twic", "twie", "twin", "twis", "twki", "twki", "twla", "twlt", "twlu", "twma", "twme", "twmo", "twoz", "twpa", "twre", "twsa", "twsp", "twtc", "twte", "twth", "twti", "twtk", "twtr", "twtw", "twua", "twuk", "twus", "twwa", "upda", "uwee", "uwet", "wman", "zero", "hjbr", "ch36", "ewds", "cmld"}
end script
store script pub_code in file thePath

and reading a value

set thePath to (path to scripts folder as Unicode text) & "pubcode.scpt"
set s to load script alias thePath
set a to item 2 of s's pub_code_List

The script aka the list can be modified normally

Hi Stefan,
This looks like what I might need, once I’ve loaded the script and then added another list item how do I then write the amended list back to the script I’ve just loaded?

set ThePath to (path to scripts folder as Unicode text) & "mag reference.scpt"
set s to load script alias ThePath
set new_entry to text returned of (display dialog "enter new Pub_Code" default answer "")
copy new_entry to end of s's pub_code_List
store script s in file thePath replacing yes

Thanks Stefan,
I think I tried everything but the obvios option! :lol:
Nik

Hi,
Stefan are you online?
sorry to open up an old post but I’m having trouble with a script I’ve created. I now have a master script that loads values from a script sitting in my Users/Scripts folder called “property list”. The purpose of the “property list” script to feed info to the master script but I also wrote a small app that would allow a user to add to a list contained in the “property list” script. This works fine, my small editor script loads new values into my “property list” script which I can pull data back ok, but when I open the “property list” script I can’t see the values that I’ve been adding even though I know there in the script when loaded by the master script. Now if I change the “property list” script in any way and save changes the next time the script is loaded using the master script the vales that I’ve added using the editor script are gone. Why can’t I see the values that I’ve been adding using my editor script?

Hi,

this is normal. You don’t see the saved changes in the properties,
when you open a compiled script (object), but no worry, they are there

Thanks for the response Stefan,
if I use my editor script to add a value to my “property list” script does that mean that the only way of removing that value from my “property list” script is to load it using another script remove it from the list and save the list back to the “property list” script using the script I used to load it in the first place? phew!!

Yes, you should use a editor scipt which includes routines for adding items to and removing items from the property list

Thanks again Stefan,
I know which direction to take now! :wink: