Mail will not set text to <<ttxt>>?

I have a script to allow myself to update my Facebook status using a dialog box and a direct email to my Facebook account. I wrote a script to accept the text from a dialog box and use this for the subject of the email to be sent to my Facebook account so the status can be updated. The script works flawlessly when only used on its own.

However, I am now trying to add the script into a bigger project and this is throwing up some issues.

here is the code for the bigger project’s Facebook portion:

-- FACEBOOK STATUS
			
			if myCommand contains "new status" then --mycommand is a variable that should be like this: "new status status goes here"
				set jarvisTag to " (sent by Jarvis)" -- this is to let people know it was automated.
				set newstatus to text returned of util's replaceText("new status ", "", myCommand) as string --this will remove the "New status" portion of mycommand and return it as newstatus.
				set theRecipient to "Facebook email goes here"
				set theSubject to {(newstatus as string) & jarvisTag} --combines the status and automation message so it would look like 'status goes here (sent by Jarvis)'
				
				tell application "Mail" --sending the message
					activate
					set statusmessage to make new outgoing message
					tell statusmessage
						set the subject to string of theSubject
						make new to recipient at end of to recipients with properties {address:theRecipient}
					end tell
					send statusmessage
					
				end tell
				
				set response to "Facebook has been updated."
				return response
				
			end if

My problem is that whenever I try to send the message then it will not send, instead just returns “can’t make <> of “status goes here” into type string”. I have googled this and ttxt is just a plain text variable. I have changed all the “as string” to “as text” and it still flags up the problem, even though variable “myCommand” will only return text to the script. some people have said to try and return the variable as “Rich text”, but my compiler (applescript editor on lion) doesn’t recognise this command and thinks the word rich is a variable.

How can i fix this problem?

John

Model: iMac
AppleScript: Version 2.4.3 (131.2)
Browser: Safari 534.56.5
Operating System: Mac OS X (10.7)

I don’t know what until is, but I suspect you want something like:

set newstatus to util's replaceText("new status ", "", myCommand) as string

Oops I totally missed that variable, util is a utility file that can be called to replace text within my scripts. It then returns the result back to the original file. I may have to look in the utility script on this one, though it works fine for twitter and everything else, returning the text as it should.

I have tried your recommnedation but it still doesn’t work. The above code is the closest I could get to a working file, but it still doesn’t recognise the text as text :confused:

Thank you for your input!

John

Leave out ‘string of’. Text has no such property.

set the subject to theSubject

Hi guys, finally managed to get the script working with a bit of tinkering, here is the final code that works:



if myCommand contains "new status" then
				set jarvisTag to " (sent by Jarvis)"
				set newstatus to util's replaceText("new status ", "", myCommand) as text
				set theRecipient to "Facebook email here"
				set theSubject to {(newstatus) & jarvisTag}
				
				tell application "Mail"
					activate
					set statusmessage to make new outgoing message
					tell statusmessage
						set the subject to theSubject
						make new to recipient at end of to recipients with properties {address:theRecipient}
					end tell
					send statusmessage
					
				end tell
				
				set response to "Facebook has been updated."
				return response


Turns out I was telling the compiler to find the text variable twice, so it was struggling. Thanks for the help!

John.