I have made this script to add a record to an AppleScript database events database. The data for the record is right in the script between the curly brackets as in examples that I’ve seen elsewhere. This works fine. The problem I have is that I have prepared a second script to gets this same data from a text file. This script reads the .txt file into a variable called theFileContents. This exact same text is not read correctly by the script. It places in the first field a “{”. it places in the second field a "" in the third field “J”. in the fourth field “o” and so on. I wold appreciate any help. I am also posting the two scripts.
--Script 1
tell application "Database Events"
tell database "ClientCopay"
set input to {{"Joe Person", "06/26/14", "06/26/14", "Anthem", "06/26/14", "130.00", "", "", "", "10.00", "20.00", "Cash", ""}}
set the field_names to {"Client Name", "Dt/Service", "Mo/Service", "Payor", "Da/Claim", "Am/Billed", "Status", "Amt Paid", "Paid Date", "Co-Pay", "Co-Paid", "Action"}
set theRecord to make new record with properties {name:""}
tell theRecord
repeat with record_data in the input
repeat with i from 1 to the count of field_names
set the field_name to item i of field_names
set the field_data to item i of record_data
make new field with properties {name:field_name, value:field_data}
end repeat
end repeat
end tell
end tell
end tell
--Script 2
set myfile to ("Macintosh HD:Users:therapy:Desktop:ClientCopay")
set theFileContents to (read file myfile)
set testData to {theFileContents}
tell application "Database Events"
tell database "ClientCopay"
set input to {theFileContents}
set the field_names to {"Client Name", "Dt/Service", "Mo/Service", "Payor", "Da/Claim", "Am/Billed", "Status", "Amt Paid", "Paid Date", "Co-Pay", "Co-Paid", "Action"}
set theRecord to make new record with properties {name:""}
tell theRecord
repeat with record_data in the input
repeat with i from 1 to the count of field_names
set the field_name to item i of field_names
set the field_data to item i of record_data
make new field with properties {name:field_name, value:field_data}
end repeat
end repeat
end tell
end tell
end tell