View Single Post
The main elements might look something like this:

Code:
on run
	set {strProj, strContext, strTask} to {"Proj1", "Context3", "TaskTitle"}
	
	MakeTask(strProj, strContext, strTask)
end run

on MakeTask(strProj, strContext, strTask)
	tell application id "OFOC"
		tell default document
			
			-- WHERE WILL IT GO (A PROJECT OR THE INBOX) ?
			if strProj ≠ "" then
				set lstProj to flattened projects where name = strProj
				if lstProj ≠ {} then
					set oProj to first item of lstProj
				else
					set oProj to make new project with properties {name:strProj}
				end if
				
				tell oProj to set oTask to (make new task with properties {name:strTask})
			else
				set oTask to (make new inbox task with properties {name:strTask})
			end if
			
			-- WHICH CONTEXT IF ANY ?
			if strContext ≠ "" then
				set lstContext to flattened contexts where name = strContext
				if lstContext ≠ {} then
					set oContext to first item of lstContext
				else
					set oContext to make new context with properties {name:strContext}
				end if
				set context of oTask to oContext
			end if
		end tell
		
		return oTask
	end tell
end MakeTask

Last edited by RobTrew; 2011-10-19 at 11:00 AM.. Reason: default document probably safer than front document