Ok, here is the code, whenever I try and call the parsing subroutine using either of the “–” lines, I get this error: “window of «class butT» id 2 of window id 1 doesn’t understand the parse_string_in message. (-1708).” I’ve spent a lot of time working this script out, mainly problems with the UI elements. Every subroutine I’ve attempted has failed.
This script basically takes the information from some text fields and generates some HTML ready for eBay. It saves a lot of time, not having to format it for HTML, especially with unnumbered lists. Then I use GarageSale to list it and it adds a footer with more HTML that appear on all the auctions.
Anyway, the interface is basically just the text fields with a non-editable text field to output the HTML. Another question, I don’t know much about linking UI elements, I tried to add an NSTextView item so that I could get some scrollable text input. At the moment the text fields aren’t scrollable nor are you able to get a line break when hitting return, even if the submit button isn’t set with a Key Equivalent. An alternative to only being able to paste paragraphs in would be great.
Thanks in advance.
property rr : return & return
property r : return
on clicked theObject
tell window of theObject
set window_title to contents of text field "title"
set top_image to contents of text field "image"
set image_height to contents of text field "height"
set image_width to contents of text field "width"
set main_description to contents of text field "main"
set features_heading to contents of text field "heading"
set features to contents of text field "features"
set condition to contents of text field "condition"
--copy parse_string_in(window_title, "&", "&") to window_title
--set window_title to parse_string_in(window_title, "&", "&")
set header to "<html>" & rr & "<head>" & r & "<meta http-equiv="content-type" content="text/html;charset=iso-8859-1">" & r & "<title>" & window_title & "</title>" & r & "</head>" & rr
set body1 to "<body bgcolor="white" topmargin="0" leftmargin="0">" & r & "<center>" & r & "<table border="5" cellpadding="5" cellspacing="0" bordercolor="CFCFCF" width="100%" bgcolor="BFBFBF">" & r & "<tr>" & r & "<td width="100%" bordercolor="#800080" align="center"><br>" & r & "<br>" & r & "<img height="" & image_height & "" img width="" & image_width & "" src="" & top_image & ""><br>" & r & "<br>" & r & "<br>" & r & "<br>" & r & "<br>" & r & "<div align="left"><br>"
set body2 to "<table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="CFCFCF">" & r & "<tr>" & r & "<td>" & r & "<div align="left">" & r & "<div align="left">" & r & "<p>" & main_description & "</p>" & r & "</div>" & r & "</div>" & r & "</td>" & r & "</tr>" & r & "</table>" & r & "<br>"
set body3a to "<table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="CFCFCF">" & r & "<tr>" & r & "<td>" & r & "<div align="left">" & r & "<div align="left">" & r & "<p><b>" & features_heading & "</b></p>" & r & "<ul>" & r
set feature_list to paragraphs of features
set features_html to {}
repeat with n from 1 to (count of feature_list)
set feature_line to item n of feature_list
set features_html to features_html & ("<li type="circle">" & feature_line & return) as string
end repeat
set body3b to features_html
set body3c to "</ul>" & r & "</div>" & r & "</div>" & r & "</td>" & r & "</tr>" & r & "</table>" & r & "<br>"
set body4 to "<table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="CFCFCF">" & r & "<tr>" & r & "<td>" & r & "<div align="left">" & r & "<div align="left">" & r & "<p>" & condition & "</p>" & r & "</div>" & r & "</div>" & r & "</td>" & r & "</tr>" & r & "</table>" & r & "</div>" & r & "</td>" & r & "</tr>" & r & "</table>" & r & "</center>" & r & "</body>" & r & r & "</html>"
if features is "" then
set code to header & body1 & body2 & body4
else
set code to header & body1 & body2 & body3a & body3b & body3c & body4
end if
set contents of text field "html" to code
end tell
end clicked
on parse_string_in(s, f, r)
set astids to AppleScript's text item delimiters
try
set AppleScript's text item delimiters to f
set s to s's text items
set AppleScript's text item delimiters to r
set s to s as string
set AppleScript's text item delimiters to astids
return s
on error e number n from f to t partial result p
set AppleScript's text item delimiters to astids
error e number n from f to t partial result p
end try
end parse_string_in