How will I retrieve my data from a file using property

Hi (Happy New Year)

I am having trouble and I am new in Eggplant.

Goal: I am trying to enter data in web registration form to register multiple students using eggplant.

Just for example: Here is my data looks like

name: “johnson” email “” code: "12345, name: “allen” email “” code: "12045,

{please suggest if my data format is wrong, or the best way to achieve my goal}

My example code:

put file"~/Desktop/test" into list

repeat with each student in list
put student
end repeat

Result from this code: showing all my data along with property, I understand why it is showing all my code. I have tried few different ways but with no success :wink:


  1. How do I retrieve my desire data using property feature

Thanks in advance

There are lots of ways to go about formatted data but since you mention wanting to use the Property list feature we’ll go with that.

The proper format for Property lists is (key1:value1, key2:value2, …)

For your data file you probably want to have it separated by newlines so your example file “test”, should look like this:

(name: "johnson", email: "", code: "12345")
(name: "allen", email: "", code: "12045")

Since we are reading those by line (rather than by each comma separated value) we want to use the phrase “each line of” in the repeat statement. That will put each line into a temporary variable called it. In order to evaluate that string into a SenseTalk property list we use the value() function.

Now we have a full property list that we can use to query it’s keys and values the way you would like to.

put file "~/Desktop/test" into list 

repeat with each line of list 
	put value(it) into student
	put student's name
	put values(student) -- print all values
end repeat 

Hi Jonathan

this is great

In this case my data have to associate with property and that is so much redundent property data in one place. At least I have learned, how to deal with properties.

could you please present me another example where my data doesn’t associate with property then and I could use the data in forms?

thank you so much


If you don’t want to have to specify the property name on each line in your data file, you can make a simpler file with values separated by commas or other separator:


Then you can read this file using code like this:

repeat with each line of file "~/Desktop/test" 
   put it split by "," into student's (name,email,code)
   put student's name 
   put values(student) -- print all values 
end repeat