Re: Database events
Re: Database events
- Subject: Re: Database events
- From: Axel Luttgens <email@hidden>
- Date: Thu, 08 Jan 2015 00:54:31 +0100
Le 7 janv. 2015 à 16:31, Fred Diepeveen a écrit :
> I hope someone can help me.
>
> I'm creating a database that replaces a (fare too) large Excel spreadsheet. It is slowing down and can handle only one active process without generating mismatches between sheets.
>
> For this I'm learning how the commands in applescript Database Events work. I got stuck up using this command:
>
> every record whose value of the field "Year" is "2008"
>
> which gives an error:
>
> error "Database Events kreeg een fout: field \"Year\" kan niet worden opgevraagd. " number -1728 from field "Year"
>
> [...]
Hello Fred,
Database Events is a bit surprising, yet works rather well and even proves quite powerful (strictly limited to a single table in a DB parlance, yet with potentially variable records).
Following code works with Mavericks, and should be just seen as a proof of concept of what your code intended to do.
set lokatie to path to desktop -- better to have a specialized folder...
set dbnaam to "cars"
set dbweg to POSIX path of ((lokatie as text) & dbnaam)
tell application "Database Events"
try
set db to database dbweg
on error
set db to make new database with properties {name:dbnaam, location:lokatie}
tell db
set rec to make new record with properties {name:"Renault"}
tell rec
make new field with properties {name:"Model", value:"Espace"}
make new field with properties {name:"Year", value:"2008"}
end tell
set rec to make new record with properties {name:"Toyota"}
tell rec
make new field with properties {name:"Model", value:"Yaris"}
make new field with properties {name:"Year", value:"2010"}
end tell
save
end tell
end try
tell db
value of fields of (records whose value of field "Year" is "2008")
end tell
quit
end tell
HTH,
Axel
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden