Yet Another ClickLine Question

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
WaltBrown
Posts: 466
Joined: Mon May 11, 2009 9:12 pm

Yet Another ClickLine Question

Post by WaltBrown » Thu Feb 26, 2015 1:27 am

Using 7.0.1 Community on Win7 X64 this code in a field:

Code: Select all

on mouseUp
   local tClickLine
   put the clickLine into tClickLine
   delete tClickLine
end mouseUp
ignores the delete command completely (about half of the time) or produces:
field "fRGB": execution error at line n/a (Object: stack locked, or object's script is executing)
from the delete command. There are no other scripts running. Sometimes when I close everything and reopen, 7.0.1 ignores the first click, and ALL subsequent clicks on the field produce the error.

On 5.5.5 and 6.6.2, the line is deleted correctly the first time, and on all further clicks the delete is ignored, but no error is thrown. If I open the script editor for the field, add an empty line, then close it, it again functions once then is ignored.

It's almost like local variables are actually storing references, and when I do anything with "clickLine", which empties it, also appears to do it to local variables assigned it's value.

My slightly cumbersome workaround is:

Code: Select all

on mouseUp
   local tClickLine
   put word 2 of the clickLine into tClickLine
   delete line tClickLine of me
end mouseUp
Any thoughts? Thanks, Walt
Walt Brown
Omnis traductor traditor

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10305
Joined: Wed May 06, 2009 2:28 pm

Re: Yet Another ClickLine Question

Post by dunbarx » Thu Feb 26, 2015 3:54 am

Hi.

In v. 6.7 ( and I would bet in all versions back to HC 1.0) this works first time, every time. I did try it in v. 5.5 for you.

Now, I am on a Mac. Perhaps it is something In Windows or 7.x?

Craig Newman

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10043
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Yet Another ClickLine Question

Post by FourthWorld » Thu Feb 26, 2015 4:57 am

Is it a list field?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10305
Joined: Wed May 06, 2009 2:28 pm

Re: Yet Another ClickLine Question

Post by dunbarx » Thu Feb 26, 2015 5:21 am

Richard.
Is it a list field?
How would that matter?

Craig

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10043
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Yet Another ClickLine Question

Post by FourthWorld » Thu Feb 26, 2015 6:59 am

dunbarx wrote:Richard.
Is it a list field?
How would that matter?
Not much; I just hilitedLine simpler to work with, but it's only available for list fields.

A workaround would be to get word 2 of the clickline and then refer to it explicitly, e.g.:

Code: Select all

put word 2 of the clickLine into tLine
delete line tLine of me
That said, because the original syntax works in earlier versions and fails in v7 (both confirmed here under Ubuntu 14.04) I would suggest filing a bug report on this.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

keram
Posts: 340
Joined: Fri Nov 08, 2013 4:22 am

Re: Yet Another ClickLine Question

Post by keram » Thu Feb 26, 2015 10:13 am

WaltBrown wrote:Using 7.0.1 Community on Win7 X64 this code in a field:
Works OK in Win7x64 with LC 6.7.2 Community
Using the latest stable version of LC Community 6.7.x on Win 7 Home Premium, 64bit

WaltBrown
Posts: 466
Joined: Mon May 11, 2009 9:12 pm

Re: Yet Another ClickLine Question

Post by WaltBrown » Thu Feb 26, 2015 3:43 pm

Here is a more detailed demonstration stack. The explanations are in the stack. Basically two fields, one using "the clickLine", and one assigning "the clickLine" to a local variable. Tested on Win7 x64 LC 5.5.5, 6.6.2, and 7.0.1, differences noted in stack.

Questions raised:

1. Should "Answer" clear "the clickLine"? I vote No, since "Answer" takes no action on the field, while "Delete" does in which case clearing "the clickLine" is appropriate.
2. Should "Delete <empty>" do nothing or throw an error? It sometimes throws an error. "Answer <empty>" does not. I vote "Delete <empty>" should do just that, nothing, because that's what you are telling it to do. It should be a coding issue, not an LC captured error.
3. What exactly gets reset when a script is edited? Something is getting reset behind the scenes. I vote that it should be visible and/or explained in some detail. (The "Modify The Script" button proves this by again allowing a different first click result - all it does is copy and replace the script after adding a single space to it).
4. Is "the clickLine" (and/or other functions) actually getting their value passed (and acted on!) by reference rather than value? The behavior in this stack in the "fRGB" field opens the question. Or maybe...
5. If a line in a text field is deleted, how are the contents of the field organized internally afterwards? Is there a hidden structure of line numbers that does not get fully normalized after the deletion? Is it saved internally as XML, sorted by available line number, and not fully corrected for consecutive line numbers after line deletion? (I'm just hypothesizing here).

The email from Richard Gaskin (http://forums.livecode.com/viewtopic.ph ... 87#p121017) relates to the hypothesis in point 4.

Sorry for the OCD on this issue.

Thanks, Walt
Attachments
idColorLab.zip
(12.71 KiB) Downloaded 516 times
Walt Brown
Omnis traductor traditor

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10043
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Yet Another ClickLine Question

Post by FourthWorld » Sat Feb 28, 2015 2:05 am

"Pass by reference" refers to values passed to handlers as parameters. Function calls like clickLine are inherently values themselves, so I don't see how passing by reference could come into play there.

A few posts back I suggested that if you find syntax that works in earlier versions but not in v7 it would be helpful if you'd submit a bug report. Looks like your example stack illustrates the issue clearly. Bug reports can be filed here:
http://quality.runrev.com/
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

WaltBrown
Posts: 466
Joined: Mon May 11, 2009 9:12 pm

Re: Yet Another ClickLine Question

Post by WaltBrown » Sat Feb 28, 2015 2:40 pm

Walt Brown
Omnis traductor traditor

Post Reply