text edit: using bold text

Below is a part of my script.
Is it possible to tell text edit to use bold text?
For example: only “archivejob” must be bold

property archivedir : "/Volumes/Archief/DTP/test"
property parentdir : "/Volumes/DTP"
property archivedir_p : "/Volumes/Archief/DTP/test/permanent"
property archivedir_t : "/Volumes/Archief/DTP/test/tijdelijk"
property p_dups : "/dups"

set chosenfile to (choose file)
set filecont to read chosenfile
set archivejobs to paragraphs of filecont

tell application "TextEdit"
	activate
	close every document saving no
	make new document
	set the name of window 1 to "Archive Info"
	set currentText to text of front document
	set newText to currentText & return & "Starting archiving " & (current date) & return & return
	set text of front document to newText
end tell

try
	do shell script "cd " & archivedir_p & p_dups
on error
	do shell script "/bin/mkdir -p " & archivedir_p & p_dups
end try

repeat with archivejob in archivejobs
	
	set {tid, AppleScript's text item delimiters} to {AppleScript's text item delimiters, {" "}}
	set pgraphParts to text items of archivejob
	set testResult to false
	
	try
		set testResult to (((item 1 of pgraphParts) + 0) = item 1 of pgraphParts as integer)
		set testResult to testResult and {"t", "p"} contains (second item of pgraphParts)
	end try
	
	set testResult to testResult and (length of archivejob = 7)
	
	if testResult then
		tell application "TextEdit"
			set currentText to text of front document
			set newText to currentText & return & "this " & archivejob & " is  correct " & (current date) & return
			set text of front document to newText
		end tell
end repeat

– Peter –

HI! Try with this feature to append data to TextEdit instead of paste and copy. :slight_smile:
Tested with PPC G4 10.4.11



property archivedir : "/Volumes/Archief/DTP/test"
property parentdir : "/Volumes/DTP"
property archivedir_p : "/Volumes/Archief/DTP/test/permanent"
property archivedir_t : "/Volumes/Archief/DTP/test/tijdelijk"
property p_dups : "/dups"

set chosenfile to (choose file)
set filecont to read chosenfile
set archivejobs to paragraphs of filecont

tell application "TextEdit"
	activate
	close every document saving no
	make new document
	set the name of window 1 to "Archive Info"
	set currentText to text of front document
	set newText to currentText & return & "Starting archiving " & (current date) & return & return
	set text of front document to newText
end tell

try
	do shell script "cd " & archivedir_p & p_dups
on error
	do shell script "/bin/mkdir -p " & archivedir_p & p_dups
end try

repeat with archivejob in archivejobs
	
	set {tid, AppleScript's text item delimiters} to {AppleScript's text item delimiters, {" "}}
	set pgraphParts to text items of archivejob
	set testResult to false
	
	try
		set testResult to (((item 1 of pgraphParts) + 0) = item 1 of pgraphParts as integer)
		set testResult to testResult and {"t", "p"} contains (second item of pgraphParts)
	end try
	
	set testResult to testResult and (length of archivejob = 7)
	
	if testResult then
		set endText to (" is correct " & (current date) & return & return)
		
		my appendMe(false, false, true, "this ")
		my appendMe(true, false, true, archivejob)
		my appendMe(false, false, false, endText)
		
		(*
       tell application "TextEdit"
           set currentText to text of front document
           set newText to currentText & return & "this " & archivejob & " is correct " & (current date) & return
           set text of front document to newText
       end tell
		*)
		
	end if
end repeat




on appendMe(boldText, redText, spacedText, theString)
	tell application "TextEdit"
		activate
		if text of front document is "" then tell application "System Events" to keystroke return
		-- set last character of document 1 to (last character of document 1 & return)
		set savedFont to font of last character of document 1
		set savedColor to color of last character of document 1
		if boldText is true then set font of last character of document 1 to "Helvetica-Bold"
		if redText is true then set color of last character of document 1 to {65535, 18601, 19374}
		if spacedText is true then
			set last character of document 1 to (last character of document 1 & theString & " ")
		else
			set last character of document 1 to (last character of document 1 & theString)
		end if
		set font of last character of document 1 to savedFont
		set color of last character of document 1 to savedColor
		-- set last character of document 1 to (last character of document 1 & return)
	end tell
end appendMe


Post #2 here shows how…
http://macscripter.net/viewtopic.php?id=24219