• 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
Re: Find Item in AppleWorks Database?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Find Item in AppleWorks Database?


  • Subject: Re: Find Item in AppleWorks Database?
  • From: Ian York <email@hidden>
  • Date: Sun, 28 Nov 2004 16:43:42 -0500

Date: Sun, 28 Nov 2004 10:12:09 -0700
From: "Ken G. Brown" <email@hidden>
Subject: Find Item in AppleWorks Database?
To: email@hidden


I'm new to AppleScript and have a simple little task I want to automate.
I need to open a AppleWorks database file, search for an item in the
database and of course then display it.


Can anyone point me to appropriate examples that could help me get
jump started?

Just the other day I wrote a script that does that does the search part. (The point was to search for two items, this AND that, which I don't think the built-in search will do.) I didn't bother making it customizable, and there's not really a "display" part, other than in the dialog. I make no warranty, blah blah blah. But this might be an example, anyway.


(*
Search "Plasmids" (or other front database in Appleworks) for multiple terms at once
*)
tell application "System Events"
set AllProcesses to name of every process
end tell


if not (AllProcesses contains "Appleworks") then
tell application "Finder" to open "Ian's Powerbook:Users:iayork:Lab:Lab Documents:Lab records:Plasmids.cwk"
else
tell application "AppleWorks 6"
activate
set the front document to document "Plasmids.cwk"
end tell
end if


tell me to activate
set AllSearch to {}
set TheResult to display dialog "Enter search terms, separated by commas: " default answer ""
set SearchTerms to text returned of TheResult
set TID to AppleScript's text item delimiters
set AppleScript's text item delimiters to ","
repeat with i from 1 to number of text items in SearchTerms
set AllSearch to AllSearch & text item i of SearchTerms
end repeat
set AppleScript's text item delimiters to TID


set string1 to "get every record of front document whose "
set string1A to "get every record of front document whose "
repeat with i from 1 to ((number of items in AllSearch) - 1)
set string2 to "(value of field " & "1" & ") contains \"" & item i of AllSearch & "\" and "
set string1 to string1 & string2
set string2A to "(value of field " & "4" & ") contains \"" & item i of AllSearch & "\" and "
set string1A to string1A & string2A

end repeat
set string3 to "(value of field " & "1" & ") contains \"" & item -1 of AllSearch & "\""
set string3A to "(value of field " & "4" & ") contains \"" & item -1 of AllSearch & "\""


set IfString to string1 & string3
set IfStringA to string1A & string3A

tell application "AppleWorks 6"
set ThePlasmids to run script IfString
set MorePlasmids to run script IfStringA
repeat with APlasmid in MorePlasmids
if not (ThePlasmids contains APlasmid) then copy APlasmid to end of ThePlasmids
end repeat
if ThePlasmids is {} then display dialog "No matches found"

repeat with i from 1 to number of items in ThePlasmids
set APlas to item i of ThePlasmids
display dialog ("Record " & i & " of " & number of items in ThePlasmids & ":" & return & return & "Plasmid: " & (|Plasmid| of APlas) as string) & return & "Description: " & ((|Description:| of APlas) as string)
end repeat
end tell



-- Ian York, Ph.D. S2-116, UMMC, 55 Lake Ave, Worcester MA 01655 (508) 856-7534 phone (508) 856-1094 fax

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Prev by Date: System Events vs Finder
  • Next by Date: Re: System Events vs Finder
  • Previous by thread: Re: Find Item in AppleWorks Database?
  • Next by thread: System Events vs Finder
  • Index(es):
    • Date
    • Thread