I am making an AppleScript application with AppleScript 2.2 on Mac OS X 10.7 (Build: 11A511) Lion. What my application is doing is capturing the current iTunes song and storing it if the song is different from the last one. Then I told it to take the the current song and place it into an SQLite file using Database Events. Basically it is adding the current song to a new field, but when the song changes it says that there are no old fields and then writes the song (the process repeats...); I do have a save after it makes the field.
My code is as follows:
if currentsong is not equal to previous_song then
tell application "Database Events"
tell database "songlist"
set song to make new record with properties {name:"songs"}
set song_count to count fields
tell song
make new field with properties {name:currentsong, value:song_count + 1}
end tell
end tell
save database "songlist"
end tell
end if