Generating Variables in a Repeat loop
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
-
- VIP Livecode Opensource Backer
- Posts: 9660
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: Generating Variables in a Repeat loop
Richard.
"Works" means it works. I was just commenting on how loose and forgiving LC can be interpreting its own syntax.
If there is no "find", there is no foundChunk, which means there is no target chunk, and you get an error.
Craig
"Works" means it works. I was just commenting on how loose and forgiving LC can be interpreting its own syntax.
If there is no "find", there is no foundChunk, which means there is no target chunk, and you get an error.
Craig
-
- VIP Livecode Opensource Backer
- Posts: 9834
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
- Contact:
Re: Generating Variables in a Repeat loop
I may not be as smart as you, since as helpful as that description is I still don't understand what useful outcome that syntax produces.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
-
- VIP Livecode Opensource Backer
- Posts: 7233
- Joined: Sat Apr 08, 2006 8:31 pm
- Location: Minneapolis MN
- Contact:
Re: Generating Variables in a Repeat loop
Just for reference, "value" has the same overhead and speed hit as "do". I almost never need "do" but I find I need "value" slightly more often. I try to avoid both though, ever since I found out they need to load the whole compiler into RAM on each use.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
-
- VIP Livecode Opensource Backer
- Posts: 9660
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: Generating Variables in a Repeat loop
Richard.
I was not being flip with you.
LC allows one to include both "the" and "()" in the same line:
That is all I meant. I am constantly surprised at how LC seems to be even more forgiving than HC, almost to a fault. I am thinking of two "lines" of code being allowed to live in a single physical line, without a semicolon. That sort of thing. It allows sloppy code to run. I shudder whenever I see such a thing.
Craig
I was not being flip with you.
LC allows one to include both "the" and "()" in the same line:
Code: Select all
put "25" into the foundChunk()
Craig
-
- VIP Livecode Opensource Backer
- Posts: 9834
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
- Contact:
Re: Generating Variables in a Repeat loop
What does "run" mean there? What happens when that statement is executed?dunbarx wrote: ↑Tue Jun 12, 2018 5:28 pmRichard.
I was not being flip with you.
LC allows one to include both "the" and "()" in the same line:That is all I meant. I am constantly surprised at how LC seems to be even more forgiving than HC, almost to a fault. I am thinking of two "lines" of code being allowed to live in a single physical line, without a semicolon. That sort of thing. It allows sloppy code to run.Code: Select all
put "25" into the foundChunk()
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
-
- VIP Livecode Opensource Backer
- Posts: 9660
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: Generating Variables in a Repeat loop
Richard.
LC runs the following line of code:
without issue.
It allows both "the" and "()", that is, both synonym forms together.
Anyway,
None of that matters anymore. I just don't know what to do. All of a sudden, this works fine:
It did not before, and by before, I mean forever.
And to boot, if I run this:
I get an error:
I am depressed.
Craig
LC runs the following line of code:
Code: Select all
put "25" into the foundChunk()
It allows both "the" and "()", that is, both synonym forms together.
Anyway,
None of that matters anymore. I just don't know what to do. All of a sudden, this works fine:
Code: Select all
on mouseUp
find "xyz" in fld 1
put "AHA!" into the foundChunk
end mouseUp
And to boot, if I run this:
Code: Select all
find "xyz" in fld 1
do "put AHA! into" && the foundChunk
This is exactly what "do" was supposed to do. Reads fine, no?do: error in source expression) near "put AHA! into char 9 to 11 of field 1"!
I am depressed.
Craig
-
- VIP Livecode Opensource Backer
- Posts: 7233
- Joined: Sat Apr 08, 2006 8:31 pm
- Location: Minneapolis MN
- Contact:
Re: Generating Variables in a Repeat loop
Maybe it now needs the quotes around the literal, along with all the ampersand concatenation. That's another reason I don't like doing do.
Code: Select all
do "put" && quote & "AHA!" & quote && "into" && the foundChunk
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
-
- VIP Livecode Opensource Backer
- Posts: 9834
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
- Contact:
Re: Generating Variables in a Repeat loop
Ah, thanks. If I understand correctly, the concern is that it's possible to come up with certain syntactic sequences which produce no adverse results but are not flagged as errors.dunbarx wrote: ↑Tue Jun 12, 2018 6:35 pmLC runs the following line of code:without issue.Code: Select all
put "25" into the foundChunk()
It allows both "the" and "()", that is, both synonym forms together.
I suppose you could submit a bug report for more thorough error-checking for that specific sequence.
I apologize if I seemed dense before, but I had not previously considered "works" to mean "it does no work"; helpful to know that it as used here it simply means "does no work and produces no result, but merely isn't flagged as invalid syntax".None of that matters anymore. I just don't know what to do. All of a sudden, this works fine:It did not before, and by before, I mean forever.Code: Select all
on mouseUp find "xyz" in fld 1 put "AHA!" into the foundChunk end mouseUp
Given all the possible ways one can imagine putting statements and symbols together in LiveCode, I suspect that error-checking sufficient to account for the combinatorial explosion of all possible cases would bump engine size up quite a lot. If we see a good many others having their work stopped by trying to put values into functions I'm sure the team will prioritize it appropriately.
For myself, it would seem simpler for the team and more useful to scripters to just flag the use of property syntax for function calls as deprecated. Not to remove support, but just stop telling new users to do that, and over time the code containing such unnecessary ambiguity will get ever smaller organically without further effort.
Yep, it seems the concatenation requirements for using "do" definitely increase cognitive load.And to boot, if I run this:I get an error:Code: Select all
find "xyz" in fld 1 do "put AHA! into" && the foundChunk
This is exactly what "do" was supposed to do. Reads fine, no?do: error in source expression) near "put AHA! into char 9 to 11 of field 1"!
When in doubt, try parentheses. This isn't a case where it's worth trying, of course, since this whole exercise seems focused on parser exploration more than any actual task needed to produce software. But should we come across something we actually care about, sometimes evaluation can be nudged toward what we want when we make it super-explicit with parens.
Why?I am depressed.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
-
- VIP Livecode Opensource Backer
- Posts: 9660
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: Generating Variables in a Repeat loop
I am depressed because all of a sudden I do not know how this stuff works.
I made a button handler that performed as I originally posted. That performed the way it always did, as I said, back to Danny Goodman. I tested it just to be sure. Yep. just as advertised.
Then I tried it again today, and the functionality reversed itself. The straight "put" line works flawlessly, the "do" line will not run.
I, like everyone else, often comes up against seemingly impossible or absurd situations where the issue cannot possibly be with us. It has to be a gremlin. Always, it is us. Of course it is.
This one is a gremlin, and I am not sure I like it. That is depressing.
Craig
I made a button handler that performed as I originally posted. That performed the way it always did, as I said, back to Danny Goodman. I tested it just to be sure. Yep. just as advertised.
Then I tried it again today, and the functionality reversed itself. The straight "put" line works flawlessly, the "do" line will not run.
I, like everyone else, often comes up against seemingly impossible or absurd situations where the issue cannot possibly be with us. It has to be a gremlin. Always, it is us. Of course it is.
This one is a gremlin, and I am not sure I like it. That is depressing.
Craig
-
- VIP Livecode Opensource Backer
- Posts: 9834
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
- Contact:
Re: Generating Variables in a Repeat loop
What did the line do previously?dunbarx wrote: ↑Tue Jun 12, 2018 9:26 pmI am depressed because all of a sudden I do not know how this stuff works.
I made a button handler that performed as I originally posted. That performed the way it always did, as I said, back to Danny Goodman. I tested it just to be sure. Yep. just as advertised.
Then I tried it again today, and the functionality reversed itself. The straight "put" line works flawlessly, the "do" line will not run.
And what changed between the working and non-working states?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
-
- Posts: 6
- Joined: Mon Jun 11, 2018 12:20 pm
Re: Generating Variables in a Repeat loop
Wow, that was a lot more input then I expected You are an awesome community, thanks a lot!
Even though I dind't understand everything I think I got the quint essence: Try to use something else than "Do", e.g. arrays.
And an array makes a lot more sence in my case, the variables will contain timesptamps in the end. I just dind't think about using an array.
Best regards,
Leo
Even though I dind't understand everything I think I got the quint essence: Try to use something else than "Do", e.g. arrays.
And an array makes a lot more sence in my case, the variables will contain timesptamps in the end. I just dind't think about using an array.
Best regards,
Leo
-
- VIP Livecode Opensource Backer
- Posts: 9660
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: Generating Variables in a Repeat loop
I feel like I ought to start a new thread.
Today, both these work:
the "do" construction did not yesterday.
The day before, the whole point of my earlier post, only the "do" worked.
Apparently, the problem is which day of the week one is programming. I will monitor this situation and report back.
@Jacque. The fully "expanded" do construction worked, as it ought to, but I do not know if this is only for Wednesdays.
Craig
Today, both these work:
Code: Select all
put "AHA" into the foundChunk
do "put AHA into" && the foundChunk
The day before, the whole point of my earlier post, only the "do" worked.
Apparently, the problem is which day of the week one is programming. I will monitor this situation and report back.
@Jacque. The fully "expanded" do construction worked, as it ought to, but I do not know if this is only for Wednesdays.
Craig
-
- VIP Livecode Opensource Backer
- Posts: 7233
- Joined: Sat Apr 08, 2006 8:31 pm
- Location: Minneapolis MN
- Contact:
Re: Generating Variables in a Repeat loop
No problem, just have your script check the day of the week and run the appropriate line of script.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
Re: Generating Variables in a Repeat loop
Hi Craig,
yesterday you wrote:
...
do "put AHA! into" && the foundChunk
...
But today you wrote:
...
do "put AHA into" && the foundChunk
...
Obviously we can use strings WITHOUT quotes as long as certain characters are not part of the string, and the exclamation mark is obviously one of them.
...
put AHA into tAha
put tAha
## -> AHA
...
put AHA! into tAha
...
Script compile error:
Error description: Expression: bad factor
So this has nothing to do with DO apparently, so there is no reason to be depressed.
Best
Klaus
yesterday you wrote:
...
do "put AHA! into" && the foundChunk
...
But today you wrote:
...
do "put AHA into" && the foundChunk
...
Obviously we can use strings WITHOUT quotes as long as certain characters are not part of the string, and the exclamation mark is obviously one of them.
...
put AHA into tAha
put tAha
## -> AHA
...
put AHA! into tAha
...
Script compile error:
Error description: Expression: bad factor
So this has nothing to do with DO apparently, so there is no reason to be depressed.
Best
Klaus
-
- VIP Livecode Opensource Backer
- Posts: 7233
- Joined: Sat Apr 08, 2006 8:31 pm
- Location: Minneapolis MN
- Contact:
Re: Generating Variables in a Repeat loop
I was just about to write the same thing, but Klaus beat me to it. Removing the exclamation point fixes it. Otherwise you need the quotes.
And not quoting literals is a no-no anyway.
And not quoting literals is a no-no anyway.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com