Re: Database events
Re: Database events
- Subject: Re: Database events
- From: Bruce Robertson <email@hidden>
- Date: Wed, 07 Jan 2015 07:41:42 -0800
Life is too short.
Get a copy of FileMaker and make all this MUCH easier and more versatile.
Zillions of great built in features.
Bruce Robertson
On Jan 7, 2015, at 7:31 AM, Fred Diepeveen <email@hidden> wrote:
> 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"
>
> I've checked field values and tried examples from some 4 books on the topic Database Events.
>
> As as a background, below the scripts that creates the database, some records and some fields. Also the statements I like to use in my definite script, which are working well (except the statement with ... every: that's not working)
>
> Fred Diepeveen
> email@hidden
> + 31 6 52 00 25 00
>
>
>
> set lokatie to get POSIX path of "Macintosh HD:Users:did4you:Desktop:"
>
> tell application "Database Events"
> -- close every database
> delete every database
> -- aanmaak datbase. Naam en pad naar de naam, de database heet hier the_db
> set the_db to make new database with properties {name:"cars", location:lokatie}
> tell the_db
> -- aanmaken eerste nieuwe record in de database
> set the_record to make new record with properties {name:"Renault"}
> -- aanmaken volgende nieuwe record in de database
> make new record with properties {name:"Toyota"}
> end tell
> tell the_record
> -- aanmaken van velden in een record. Hier het eerste record
> make new field with properties {name:"Merk", value:"Renault"}
> make new field with properties {name:"Model", value:"Espace"}
> make new field with properties {name:"Year", value:"2008"}
> end tell
> -- aanamaken van velden bij het volgende record
> tell record "Toyota" of the_db
> make new field with properties {name:"Merk", value:"Toyota"}
> make new field with properties {name:"Model", value:"Yaris"}
> make new field with properties {name:"Year", value:"2010"}
> end tell
> -- opslaan van de wijzigingen. Hier met expliciete naam, anders werkt het niet lekker
> save the_db
> -- sluiten van de database. Hier met expliciete naam, anders werkt het niet lekker
> close the_db
> end tell
>
> -- lokatie is het relatieve pad naar de database, naam van het pad wordt gebruikt om database aan te wijzen
> set lokatie to get POSIX path of "Macintosh HD:Users:did4you:Desktop:cars.dbev"
>
>
> -- dit is om dubbele databases onder de zelfde naam te voorkomen
> tell application "System Events"
> exists file "cars.dbev" of folder "Macintosh HD:Users:did4you:Desktop"
> end tell
>
> if true then
>
> tell application "Database Events"
> -- dit is om te controleren of database bestaat
>
> exists lokatie
> tell database lokatie
> -- op halen gegevens uit veld van record
> get properties of field "Year" of record 1
> -- toewijzen van veld van record aan een variabele
> set car_model to value of field "Year" of record "Renault"
> tell record "Renault"
> -- 2 manieren om een veld te wijzigingen van record Renault
> -- set value of first field where its name is "Year" and its value is "2008" to "2010"
> -- set value of field "Year" to "2013"
> end tell
> get value of field "Year" of record "Renault"
> -- bepalen id van een record. 3 manieren
> set refRecord1 to record 1
> set refRecord3 to record "Renault"
> set refRecord2 to record id 439912014
>
> -- Controleren of een veld bestaat in een record. Eigen tell per record nodig
> tell record "Toyota"
> if (field "Merk" exists) = true then
> -- say "yes"
> end if
> end tell
>
> -- contoleren of een record bestaat. Hier dus opgehanden onder tell van database events
> if (record "BMW" exists) = true then
> say "no"
> end if
>
> -- haal waardes op uit een record
> tell record "Renault"
> get value of every field whose name is "Year"
> end tell
> -- every record whose value is "Model"
>
> -- every record whose value of field "Year" = " Espace"
> set theRecord to the first record whose name = "Renault"
> set theRecord to the last record whose name = "Renault"
> set theRecord to every record whose name = "Renault"
>
>
>
> -- set theRecord to every record whose value of field "Year" is "2008")
> -- set theRecord to every record whose value of the field "Year" is "2008"
> every record whose value of the field "Year" is "2008"
> --get name of every record where value of field "Model" contains "Espace"
>
> -- get name of every record where (value of field "Year" of it is "2008")
> end tell
> save lokatie
> quit
> end tell
>
> end if
>
> _______________________________________________
> 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
_______________________________________________
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