Tasklist sample
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
-
- Posts: 6
- Joined: Sun Feb 12, 2012 5:12 am
Tasklist sample
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!
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!
Re: Tasklist sample
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
HyperActive Software | http://www.hyperactivesw.com
-
- Posts: 6
- Joined: Sun Feb 12, 2012 5:12 am
Re: Tasklist sample
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
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
Re: Tasklist sample
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.
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
HyperActive Software | http://www.hyperactivesw.com
-
- Posts: 6
- Joined: Sun Feb 12, 2012 5:12 am
Re: Tasklist sample
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
Thanks for the response

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
Re: Tasklist sample
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
HyperActive Software | http://www.hyperactivesw.com
-
- Posts: 6
- Joined: Sun Feb 12, 2012 5:12 am
Re: Tasklist sample
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
Thanks for that - really appreciate your responses

Thanks again,
Patrick
Re: Tasklist sample
Hi,
It is quite simple. Just add these lines at the start of the handler:
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
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
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
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
-
- Posts: 6
- Joined: Sun Feb 12, 2012 5:12 am
Re: Tasklist sample
Hi Mark - awesome! Worked like a charm! Thanks again to you and Jacque 
Patrick

Patrick