Tasklist sample

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
impact2010
Posts: 6
Joined: Sun Feb 12, 2012 5:12 am

Tasklist sample

Post by impact2010 » Sun Feb 12, 2012 5:17 am

Hi,

I have been looking through the videos for creating the tasklist app (very good btw), and am trying to modify it for my purposes. Hit a bit of a speed bump though - if the user enters an apostrophe in the description field, the change isn't recorded. If it's escaped as a double apostrophe, it saves but then isn't able to be marked as 'complete'.

Still using the trial version so wanted to make sure this is possible before I buy.

Thanks!

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7392
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Tasklist sample

Post by jacque » Sun Feb 12, 2012 8:56 pm

It's quite possible to use apostrophes, the script probably just needs to be rewritten to account for that. Can you post the handler you're using?
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

impact2010
Posts: 6
Joined: Sun Feb 12, 2012 5:12 am

Re: Tasklist sample

Post by impact2010 » Sun Feb 12, 2012 10:09 pm

Hi Jacque,

Thanks for the response, and apologies in advance if this isn't the right info, but I think this is it (it's taken directly from the lesson 6 files in the beginners course )

on mouseUp
## Check which task we want to delete
## using the custom property set on this card when we selected a task from the list
put the cTaskID of this card into tTaskID

## Check the current completed state of the task
put taskDetail(tTaskID, "completed") into tCompleted

if tCompleted is false then
## Update the task details to say it is completed
updateTask tTaskID, field "title", field "description", "true"

## Set the icons of the completed button to allow you to toggle the state
set the icon of button "completed" to 1029
set the hiliteIcon of button "completed" to 1043
else
## Update the task details to say it is not completed
updateTask tTaskID, field "title", field "description", "false"

## Set the icons of the completed button to allow you to toggle the state
set the icon of button "completed" to 1015
set the hiliteIcon of button "completed" to 1012
end if
end mouseUp

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7392
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Tasklist sample

Post by jacque » Mon Feb 13, 2012 6:46 pm

That looks like the original script (I helped write that stack for the conference teaching session) but there's nothing in there that would cause a problem with apostrophes. There might have been a change to the "updateTask" handler that would cause trouble since the one I worked with, though the original didn't, so that's why I was wondering if you'd actually changed any of the handlers. Did you make changes to "updateTask"? Or to taskDetails?

Also, apostrophes almost never cause any trouble, but double quote marks can in some cases. Did you mean quotes? I'm pretty sure some of our original tests included entries with apostrophes.

If you changed the updateTask handler, could you post that? Actually, you'd save me some time digging around in my archives if you could post it whether you changed it or not. My old copy is buried somewhere.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

impact2010
Posts: 6
Joined: Sun Feb 12, 2012 5:12 am

Re: Tasklist sample

Post by impact2010 » Wed Feb 15, 2012 3:58 am

Hi Jacque,

Thanks for the response :) This is the update handler in the stack:

on updateTask pTaskID, pTitle, pDescription, pCompleted
## Build the SQL update statement
## Execute it
put "UPDATE tasks SET " into tSQL

if pTitle <> empty then put "title='" & pTitle & "'," after tSQL
if pDescription <> empty then put "description='" & pDescription & "'," after tSQL
if pCompleted <> empty then put "completed='" & pCompleted & "'" after tSQL

if the last character of tSQL is "," then delete the last character of tSQL

put " WHERE id='" & pTaskID & "'" after tSQL
revExecuteSQL the cDatabaseID of me, tSQL
end updateTask

Thanks again!

Patrick

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7392
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Tasklist sample

Post by jacque » Wed Feb 15, 2012 5:56 pm

I see, they've changed the code since I last saw it. It works with SQL now. I'm not great with SQL but it looks like the title is constructed using single apostrophes, and that would throw off the SQL command if it already has one in the title. Somebody who knows more than I do about constructing SQL statements might know how to get around that.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

impact2010
Posts: 6
Joined: Sun Feb 12, 2012 5:12 am

Re: Tasklist sample

Post by impact2010 » Thu Feb 16, 2012 7:33 pm

Hi Jacque,

Thanks for that - really appreciate your responses :) I'll go fish around a few places to see if I can find something.

Thanks again,

Patrick

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: Tasklist sample

Post by Mark » Fri Feb 17, 2012 12:49 am

Hi,

It is quite simple. Just add these lines at the start of the handler:

Code: Select all

replace "'" with "''" in pTitle
replace "'" with "''" in pDescription
replace "'" with "''" in pCompleted
and it should work. These lines replace single quotes ' with pairs of single quotes ''. I'm not sure that the third line is actually needed.

Kind regards,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

impact2010
Posts: 6
Joined: Sun Feb 12, 2012 5:12 am

Re: Tasklist sample

Post by impact2010 » Fri Feb 17, 2012 1:17 am

Hi Mark - awesome! Worked like a charm! Thanks again to you and Jacque :)

Patrick

Post Reply