can't remember how to do this

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9731
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

can't remember how to do this

Post by dunbarx » Wed Apr 26, 2023 9:08 pm

There is a chunk hierarchy in LC that did not exist in HC. This has been discussed here but I cannot find anything about it.

It involves using what LC considers a "large" chunk and a "small" chunk. One cannot:

Code: Select all

put foo into line 3 of item 2 of temp
because an item is "smaller" than a line. LC barks with "bad chunk order (must be small to large)"

I had thought that we solved this long ago by placing the "small" chunk in parens:

Code: Select all

put foo into line 3 of (item 2 of temp)
and even believe that in the past this worked. But it does not now. LC complains that I have a "bad destination".

No problem with an extra level of evaluation:

Code: Select all

get item 2 of temp
put foo into line 3 of it
But there was once a better way...

Craig

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9850
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: can't remember how to do this

Post by FourthWorld » Wed Apr 26, 2023 9:22 pm

You can swap the itemDel and lineDel characters.

The descending chunk order enforcement has been there as long as I can remember.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Location: Berkeley, CA, US
Contact:

Re: can't remember how to do this

Post by mwieder » Thu Apr 27, 2023 1:27 am

...and been a pain for about that long.
I've lost count of the number of times it's bitten me, and then I have to brain my way out.
"bad destination" is pedantically correct, but doesn't really give much context.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9731
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: can't remember how to do this

Post by dunbarx » Thu Apr 27, 2023 3:15 am

Richard, Mark.

Thanks for getting back to me, but am I just wrong in remembering that this was resolved by isolating the smaller chunk with parens?

I could swear it was, and that the discussion was happily resolved and put on the shelf. I even recall that official humans from the mothership stated that there need not be any revision to the way LC works (as opposed to HC) since the fix was so simple.

That fix meant inserting parentheses in the right spot. That made the engine evaluate the smaller chunk in a way that did not unnerve the chunk hierarchy.

Craig

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9850
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: can't remember how to do this

Post by FourthWorld » Thu Apr 27, 2023 4:12 am

It would seem logical that the parens would address the need, but I've never used that myself.

If you turn up anything on this (an earlier version it worked in, team comment, etc) please let us know.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

LCMark
Livecode Staff Member
Livecode Staff Member
Posts: 1211
Joined: Thu Apr 11, 2013 11:27 am

Re: can't remember how to do this

Post by LCMark » Thu Apr 27, 2023 5:24 am

dunbarx wrote:
Thu Apr 27, 2023 3:15 am
Thanks for getting back to me, but am I just wrong in remembering that this was resolved by isolating the smaller chunk with parens?

I could swear it was, and that the discussion was happily resolved and put on the shelf. I even recall that official humans from the mothership stated that there need not be any revision to the way LC works (as opposed to HC) since the fix was so simple.

That fix meant inserting parentheses in the right spot. That made the engine evaluate the smaller chunk in a way that did not unnerve the chunk hierarchy.
You are mis-remembering I'm afraid - expressions surrounded by parentheses are never containers - so the trick only works for fetching values, not storing them.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9731
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: can't remember how to do this

Post by dunbarx » Thu Apr 27, 2023 3:39 pm

LCMark.

If I am not afraid of my scrambled memory, there is no reason for you to be.

So an extra level of evaluation is the only way to circumvent the large-to-small chunk hierarchy. OK.

I may see if a "do" construction will work, since that gives that extra evaluation. But that may end up being rather less readable than simply placing the smaller chunk in a variable, as you say, merely for the privilege of keeping to a single line.

Craig

Post Reply

Return to “Talking LiveCode”