Striping text from script - help?

I don’t know if it is appropriate to ask for help in this forum. I’m sure someone will let me know if it’s not :slight_smile:

I have a system set up where I can voice dictate on my iPhone into the programs Jott or ReQall, and then have those programs transcribe my notes into text. The services will then send the transcribed text to my email (Mac Mail). I have a script that takes the added items and turns them into to do’s in my project manager program “Things.”

The problem is that the services add a bit of text before the to do. For example, ReQall adds the phrase “Added:” in front of the dictated text.

The script works fine bringing the items over to Things, but I would like to strip the added text before it posts. Is there any way to do this? I have tried a variety of approaches, but none work. I would appreciate any help.

Here is the script that takes the text from mail and adds it to Things:

using terms from application "Mail"
	on perform mail action with messages MessageList for rule Things
		tell application "Mail"
			activate
			set thisVar to (count message viewers)
			if (count message viewers) = 0 then make new message viewer
			set thisMessage to item 1 of MessageList
			set taskName to the subject of thisMessage
			set taskDesc to the content of thisMessage
			if thisVar = 0 then quit message viewer 1
			tell application "Things"
				set newToDo to make new to do with properties {name:"New to do"} at beginning of list "Today"
				set name of newToDo to taskName
				set tag names of newToDo to "ReQall"
				set notes of newToDo to taskDesc
			end tell
		end tell
		
		tell application "System Events"
			set processID to name of every process
		end tell
		if "GrowlHelperApp" is in processID then
			tell application "GrowlHelperApp"
				set the allNotificationsList to {"Things Notification"}
				set the enabledNotificationsList to {"Things Notification"}
				register as application "Remote Things Script" all notifications allNotificationsList default notifications enabledNotificationsList icon of application "Things"
				notify with name "Things Notification" title taskName description taskDesc application name "Remote Things Script"
			end tell
		end if
	end perform mail action with messages
end using terms from

Perhaps something like this will work for you


set someText to "beginining Added: other"
set tid to AppleScript's text item delimiters

set AppleScript's text item delimiters to {"Added:"}
set someItems to text items of someText

set AppleScript's text item delimiters to {""}
set strippedText to someItems as string

set AppleScript's text item delimiters to tid

return strippedText -- "beginining  other"

Thank you for the reply. But I need some help showing me exactly where the new script needs to be added to the script I posted. Perhaps you could cut and paste the two together to give me the idea?

Thanks,

Kevin

Perhaps

using terms from application "Mail"
	on perform mail action with messages MessageList for rule Things
		tell application "Mail"
			activate
			set thisVar to (count message viewers)
			if (count message viewers) = 0 then make new message viewer
			set thisMessage to item 1 of MessageList
			set taskName to the subject of thisMessage
			set taskDesc to the content of thisMessage
			
			set tid to AppleScript's text item delimiters

set AppleScript's text item delimiters to {"Added:"}
set someItems to text items of taskDesc

set AppleScript's text item delimiters to {""}
set taskDesc to someItems as string

set AppleScript's text item delimiters to tid

			if thisVar = 0 then quit message viewer 1
			tell application "Things"
				set newToDo to make new to do with properties {name:"New to do"} at beginning of list "Today"
				set name of newToDo to taskName
				set tag names of newToDo to "ReQall"
				set notes of newToDo to taskDesc
			end tell
		end tell
		
		tell application "System Events"
			set processID to name of every process
		end tell
		if "GrowlHelperApp" is in processID then
			tell application "GrowlHelperApp"
				set the allNotificationsList to {"Things Notification"}
				set the enabledNotificationsList to {"Things Notification"}
				register as application "Remote Things Script" all notifications allNotificationsList default notifications enabledNotificationsList icon of application "Things"
				notify with name "Things Notification" title taskName description taskDesc application name "Remote Things Script"
			end tell
		end if
	end perform mail action with messages
end using terms from

Thank you very much. I think one of the problems was when I added your text originally, I didn’t notice that the script was effecting the task description and not the task name. But I tweaked it and it’s working fine. For my future knowledge, is there a way to avoid the space that the script adds at the beginning of the task? Its not important here, but I would like to know for future reference. I tried elimination the two quotation marks that were the substitute for the string we were stripping, but it made no difference.

Once again, thank you. I really appreciate you taking the time to help me.

I don’t know, but it is possible that “task” is a reserved word in AppleScript. If that is the case, avoiding variable names that start with “task” would be a good idea.

In a similar vein, I once wrote a method “CommonElementsOf”. A space kept getting put in from of the “of”, so I don’t end names with “of” any more.

That makes sense. Thanks again.