Applescript and Appleworks Database "interaction"

Hi Macscripter,

I am new to Applescript. Although, I am beginning to get interested again!!! (too many late nights with macromedia lingo in the past!). I assume it is impossible to do this with Automator? (which means I would have to purchase osX Tiger)

This is module #1 of an Appleworks database project. The aim is for the terminal to be on so that when a user swipes their membership card it prompts them to input some personal details which are stored on the database.

Module#2 is, of course were the user swipes their card and the terminal dispays their details in fields in a nice interface!
I guess I will have to find a way to search the database to return the memebers correct articles.

It would be great if someone could help me get this to work, whilst at the same time educating me. As I it is the best way to learn.

Thanks drPETE (film maker)

The Appleworks Database has 4 fields: NAME; PHONE; MEMBERSHIP NUMBER; FEATURES;



tell application "Finder"
	open the file "Macintosh HD:Users:peter:Desktop:automat:new membership list.cwk"
	-- add new record
end tell

repeat with i from 1 to 5
	
	-- CREATING THE NEW MEMBER
	repeat
		set theResult to display dialog "CREATE NEW MEMBER 
Please enter your name
" default answer ""
		set theName to text returned of theResult
		set theClipboard to text returned of theResult
		if (theName does not start with "Example:") then
			exit repeat
		end if
	end repeat
	
	-- PASTE THE NEW MEMBER INTO THE DATABASE
	
	tell application "AppleWorks 6"
		activate
		tell document 1
			set current record to record i
			select current record
		end tell
		tell application "System Events" to tell process "AppleWorks 6" to tell document 1 to keystroke tab --select field 1 :MEMBER
		paste --paste the NEW NAME into field 1 in record i
		
	end tell
	
	-- ENTER THEIR PHONE NUMBER
	
	tell application "Script Editor"
	end tell
	repeat
		set theResult to display dialog "Please enter your mobile phone number" default answer "Example: +447966284765"
		set theAddress to text returned of theResult
		if (theAddress does not start with "Example:") then
			exit repeat
		end if
	end repeat
	
	-- PASTE THE NEW PHONE NUMBER INTO THE DATABASE
	
	tell application "AppleWorks 6"
		activate
		tell document 1
			set current record to record i
			select current record
		end tell
		tell application "System Events" to tell process "AppleWorks 6" to tell document 1
			repeat 2 times -- to select field 2 : PHONE NUMBER
				keystroke tab
			end repeat
		end tell
		--repeat with i from 1 to 3
		my copyTEXT
		tell document 1
			paste -- paste the clipboard into field 2 in record i
		end tell
		--end repeat
	end tell
	
	-- MEMBERSHIP NUMBER AS IT APPEARS ON THE CARD
	
	set theResult to display dialog "Please type in your membership card number?" default answer "membership number is"
	set theSubject to text returned of theResult
	
	
	-- PASTE NEW MEMBERSHIP NUMBER INTO DATABASE
	
	tell application "AppleWorks 6"
		activate
		tell document 1
			set current record to record i
			select current record
		end tell
		tell application "System Events" to tell process "AppleWorks 6" to tell document 1
			repeat 3 times --select field 3 : multimedia
				keystroke tab
			end repeat
		end tell
		--repeat with i from 1 to 3
		my copyTEXT
		tell document 1
			--		set current record to record i
			paste --paste the clipboard into field 3 in record i
		end tell
		--end repeat
	end tell
	
	
	-- TYPE IN FEATURES OF THE NEW MEMBER
	
	set theResult to display dialog "How would you describe yourself?" default answer "Female; Fair Hair; Tall etc"
	set theBody to text returned of theResult
	
	tell application "AppleWorks 6"
		activate
		tell document 1
			set current record to record i
			select current record
		end tell
		tell application "System Events" to tell process "AppleWorks 6" to tell document 1
			repeat 4 times --select field 4 : multimedia
				keystroke tab
			end repeat
		end tell
		
		my copyTEXT
		tell document 1
			paste --paste the clipboard into field 4 in record i
		end tell
		
	end tell
	
end repeat

-- SAVE THE DATEBASE FILE

on copyTEXT()
	--do stuff
	--copy image from "image events"
end copyTEXT

Model: powerBook G4
AppleScript: AppleScript 1.9.3
Browser: Safari 312.6
Operating System: Mac OS X (10.3.9)