• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Database events
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Database events


  • Subject: Database events
  • From: Fred Diepeveen <email@hidden>
  • Date: Wed, 07 Jan 2015 16:31:22 +0100

 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

  • Follow-Ups:
    • Re: Database events
      • From: Axel Luttgens <email@hidden>
    • Re: Database events
      • From: Deivy Petrescu <email@hidden>
    • Re: Database events
      • From: Bruce Robertson <email@hidden>
  • Prev by Date: Re: Script that "Tells" Finder just Focuses on Finder instead of running
  • Next by Date: Re: Database events
  • Previous by thread: Re: Putting Version and Author Info in your Apple Scripts
  • Next by thread: Re: Database events
  • Index(es):
    • Date
    • Thread