Format text data records for processing in Livecode
Simon Knight
smk at anvic.net
Tue Feb 26 18:10:11 EST 2019
Some interesting ideas although I’m not sure why a changing separator is useful. I generally attempt to stick with TSV but it won’t work in this case unless I parse the data to remove the tabs from the text, however I may well try this. At the moment I’m trying to use a simple tagging system. The AppleScript that creates the data looks like this:
-- build the data in a useful form to be read by Livecode
set tNewRec to "<REC>" & return
set tNewRec to tNewRec & "<FLD>" & "Sent : " & tDateSent & "</FLD>" & return
set tNewRec to tNewRec & "<FLD>" & "From : " & tSender & "</FLD>" & return
set tNewRec to tNewRec & "<FLD>" & "To : " & tAddresseeList & "</FLD>" & return
set tNewRec to tNewRec & "<FLD>" & "Subject : " & tSubject & "</FLD>" & return
set tNewRec to tNewRec & "<FLD>" & "Content : " & tContent & "</FLD>" & return
set tNewRec to tNewRec & "</REC>" & return
The final version will probably not add the closing tags as they seem unnecessary. I have two routines that extract the fields and put them into an array, these make use of itemdelimiter. It all works but the leading REC and FLD tags have to be ignored otherwise blank records and fields are processed. I think that replacing tabs and line returns in the source data and then saving as TSV will be simpler.
best wishes
Simon
More information about the use-livecode
mailing list