Page 1 of 1

Yet Another ClickLine Question

Posted: Thu Feb 26, 2015 1:27 am
by WaltBrown
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

Re: Yet Another ClickLine Question

Posted: Thu Feb 26, 2015 3:54 am
by dunbarx
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

Re: Yet Another ClickLine Question

Posted: Thu Feb 26, 2015 4:57 am
by FourthWorld
Is it a list field?

Re: Yet Another ClickLine Question

Posted: Thu Feb 26, 2015 5:21 am
by dunbarx
Richard.
Is it a list field?
How would that matter?

Craig

Re: Yet Another ClickLine Question

Posted: Thu Feb 26, 2015 6:59 am
by FourthWorld
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.

Re: Yet Another ClickLine Question

Posted: Thu Feb 26, 2015 10:13 am
by keram
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

Re: Yet Another ClickLine Question

Posted: Thu Feb 26, 2015 3:43 pm
by WaltBrown
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

Re: Yet Another ClickLine Question

Posted: Sat Feb 28, 2015 2:05 am
by FourthWorld
"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/

Re: Yet Another ClickLine Question

Posted: Sat Feb 28, 2015 2:40 pm
by WaltBrown