storing data

I want to build an app that can keep track of projects.
Basically each record would include: id, name, client, date

My question is how in applscript studio do you store this info? a database?
Can I use mysql as the database or am I do I need to use text files of applescript records?
Would a Document-based app be appropriate?
Sorry if these questions seem dumb, I mostly do web related programming so this type of thing is a little foreign to me.
Thanks for any input.

Nobody here stores data externally?

Nope. :wink:

Be patient mikeshank, some of us are just waking up.:stuck_out_tongue:

There are many ways to handle storing external records. Applescript has a built-in method, called the “user defaults” that automatically writes and reads plist files. Do a search for “user defaults” and you should come up with some good resources.

Using applescripts ‘read’ and ‘write’ file commands (found in the standardadditions dictionary), you can also come up with your own method of storing info. You can write a list to file and read it back in, retaining it’s list formatting. Or, with your web experience you may have used flat-file databases, utilizing pipe-delimited text files… which can also be done in applescript.

You can also use sql or just about any other kind of database, although it gets a bit complicated to go this route, as it requires use of other languages or tools, such as cgi, python, scripting additions, etc. to interface with AS.

There have been many threads at macscripter covering the topic of reading and writing external files. You just need to weigh the type, quantity, and security of the data to be stored, and determine the quantity of work you want to do to handle the data. For simple unsecure data in reasonable quantity, you’d probably be best suited to using the user defaults system. If you’re going to go wild with thousands of records and do complex searching of the DB, then you will probably need to work out a custom solution using sql and another language or a scripting addition to read/write to the DB.

Good luck,
j

Thanks, sorry for my impatience.
I would love to use mysql as I typically use it for web development and im familiar with it.
Is there a way to “do shell script” and reference external scripts rather than putting the script in AS?
I mean if i have a php shell script called shell.php can I call that with “do shell script”

Not sure, but I think it was something as

do shell script "php -o file.php"

(not sure about the -o flag, take a look to “man php” in a Terminal window)

Anyway, if your project is for personal use, you could stick with php and mysql enabling the built-in server capabilities on you mac (or using some pre-made packages, as MAMP), as you are already familiar with such languages :wink:

thanks, I used -f path/to/my/file

Another question
I have a php file writing out a list of records like so:
{name:“Joe”, client:“acme”}
{name:“Jane”, client:“acme”}

and then read them in with

set results to do shell script “/usr/local/php/bin/php -f /Users/sam/Desktop/records.php”
set resultList to results as list

it produces the list however the records are screwed because the quotes are escaped
{ {name:"Joe", client:"acme"}, {name:"Jane", client:"acme"} }

any idea what im doing wrong?

Is there a trick to storing records in a text file? I vaguely remember doing this a couple of years ago and I think there was something you need to do in order to store an applscript record in a text file.