Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

FunkEye

macrumors newbie
Original poster
May 7, 2008
7
0
I'm super new at applescript, and I'm trying to teach myself how to do some stuff, so my apologies if this is a stupid question.

Basically, I have a txt file that is a database of students. It holds their names, departments, and ID numbers. I want to be able to run a script that will allow you to enter a name and have it search the txt file to find it. I have that part so far. The next part is being able to return text objects from only that line. I am able to divide the objects on periods within a line, but I can't figure out how to tell the program to only look at the paragraph where it found the name.

Here's what I have so far:
Code:
tell application "Finder"
	set NameListFile to document file "NameList.txt" of folder "Test Scripts" of folder "AppleScript" of folder "Applications" of startup disk
end tell

tell application "TextEdit"
	close window
	display dialog "Enter Name:" default answer "Name Here"
	set FindName to text returned of result
	set NameList to read (NameListFile as alias)
	if result contains FindName then
		set tid to AppleScript's text item delimiters
		set AppleScript's text item delimiters to "."
		set ResultName to first text item of NameList
		set ResultProgram to second text item of NameList
		set ResultNumber to third text item of NameList
		set AppleScript's text item delimiters to tid
		return ResultNumber
	else
		display dialog "Name Not Found!"
	end if
end tell

I feel like it should be easy. But I've been searching for a while now, and can't find the answer.

Thanks in advance for any help.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.