Hi, I’m trying to write a script that will place 4 images (actually pdf files) in a indesign document. Each image will take a quarter of the page, then the page is to be exported as a pdf file.
I need to read the title, author, etc of each image from a tab separated text file generated through mysql, where I have title, author, date etc… Each record is separated by a line return. The file will only have 4 records to make things simpler
How can I read each line and extract variables that are separated by tabs ?
You need to look at the open file and read commands in the Standard Additions. To split each line you will need to use the text item delimiters property.
To create an applescript list of each line, I use this handler:
on GetEachRow(eachRowText)
set AppleScript's text item delimiters to return
set theList to every text item of eachRowText
set AppleScript's text item delimiters to ""
return theList
end GetEachRow
To create an applescript list of a line of tab seperated data, you could use
on GetEachValue(theLine)
set AppleScript's text item delimiters to tab
set theList to every text item of theLine
set AppleScript's text item delimiters to ""
return theList
end GetEachValue
You could also use the do shell script command to access mysql directly, and that way you might not have to create a file that you then have to read.