problem putting values into variable:possible bug?

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
Carlo Diano
Posts: 3
Joined: Thu Sep 12, 2013 10:26 pm

problem putting values into variable:possible bug?

Post by Carlo Diano » Fri May 22, 2015 10:15 pm

I am on a Mackbook air ( iOS 10.10.3.) running Livecode 7.0.5.
I set the property explicitVariables to false, which I also confirmed through the message box, however, when I try to put a field into a variable, I got the following message
"button "strip letters": compilation error at line 2 (Chunk: can't create a variable with that name (explicitVariables?)) near "x", char 43"
.
Here is the very simple code I am using that generated the error message described above

Code: Select all

on mouseUp
   put the number of lines of fld "strip" into x
   repeat with 1=1 to noLines
      put  the second item of line i of fld "strip   " & return after fld"scramble"
   end repeat
end mouseUp
I had the same problem before, running livened 7.0.1. Thanks

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: problem putting values into variable:possible bug?

Post by Simon » Fri May 22, 2015 10:30 pm

Hi Carlo,
Welcome to the forum.

This sounds like you have Strict Compilation Mode enabled which will force you to define x before you use it
local x
on mouseUp
...


Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

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

Re: problem putting values into variable:possible bug?

Post by FourthWorld » Fri May 22, 2015 10:30 pm

In that handler the variable "nolines" has not been assigned a value.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

Carlo Diano
Posts: 3
Joined: Thu Sep 12, 2013 10:26 pm

Re: problem putting values into variable:possible bug?

Post by Carlo Diano » Fri May 22, 2015 10:41 pm

FourthWorld wrote:In that handler the variable "nolines" has not been assigned a value.
That is true, however it is irrelevant to my problem; I changed the name of the variable to x from nolines in order to verify that was nothing going on at the level of the name chose for the variable. I hope this clarifies things, Thanks for your reply!

Carlo Diano
Posts: 3
Joined: Thu Sep 12, 2013 10:26 pm

Re: problem putting values into variable:possible bug?

Post by Carlo Diano » Fri May 22, 2015 10:52 pm

Simon wrote:Hi Carlo,
Welcome to the forum.

This sounds like you have Strict Compilation Mode enabled which will force you to define x before you use it
local x
on mouseUp
...


Simon
Hello Simon,
thank you so much! That was exactly where the problem lied. So, if I understood correctly, the strict compilation mode "overpowers" the set to false of the explicitVariables property. Thanks again! Carlo

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7403
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: problem putting values into variable:possible bug?

Post by jacque » Sat May 23, 2015 4:52 pm

Code: Select all

repeat with 1=1 to noLines
I'd think using an integer as the counting variable would also be illegal. It should be something like:

Code: Select all

repeat with tCount = 1 to noLines
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

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

Re: problem putting values into variable:possible bug?

Post by dunbarx » Sat May 23, 2015 11:45 pm

Jacque.

And the rest of the planet.

I would have bet money that the construction:

Code: Select all

repeat with 1=1 to whatever
was indeed illegal. It is not:

Code: Select all

on mouseUp
   repeat with 1 = 1 to 3
      answer 1 * 5
   end repeat
end mouseUp
Now you only get a bunch of "5's", so the construction is not particularly useful, but no error is thrown. And I am not sure what the parser is doing there, multiplying 5 by the, er index variable "1", or the number "1". (Smoke rising from top of head)

I did play around with a few variations, and found that something like this:

Code: Select all

on mouseUp
   repeat with 1 = 1 to 3
      put "xyz" into 1
   end repeat
end mouseUp
threw what I would expect it to at compile time, a bad chunk destination.

I found another way to get an error with the same sort of nonsense, not at compile time, but rather at runTime, and the error was "...bad destination (numeric?)". But I cannot remember what I did to get it.

Anyway, stay away from that sort of thing.

Craig Newman

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7403
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: problem putting values into variable:possible bug?

Post by jacque » Sun May 24, 2015 12:07 am

Interesting. The compiler may be interpreting it as (1=1) so it becomes "repeat with true to 3". And then when it tries to deal with that it produces garbage. Or something.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

SparkOut
Posts: 2961
Joined: Sun Sep 23, 2007 4:58 pm

Re: problem putting values into variable:possible bug?

Post by SparkOut » Sun May 24, 2015 1:32 am

Typo? 1=1 I think is supposed to be i=1 as in the original post Carlo goes on to say
put the second item of line i ...
That doesn't explain issues with the engine interpreting 1=1 this way though. I think you have it, described in the post above this one jaque

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

Re: problem putting values into variable:possible bug?

Post by dunbarx » Sun May 24, 2015 1:41 am

Yes and no, that is to say, no.

Both:

Code: Select all

repeat with true to 3

and

repeat with "true" to 3
will not compile. I am frightened to death to try:

Code: Select all

do "repeat with true to 3"
Craig

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7403
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: problem putting values into variable:possible bug?

Post by jacque » Sun May 24, 2015 2:31 am

Oh, right, I'm sure it's a typo now that you mention it. But the tangent has been interesting.

Craig, what's the worst that could happen? So what if you have to restore your hard drive from backups? :-D
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

SparkOut
Posts: 2961
Joined: Sun Sep 23, 2007 4:58 pm

Re: problem putting values into variable:possible bug?

Post by SparkOut » Sun May 24, 2015 9:25 am

So what if there is no backup to use because the implosion created a black hole and swallowed it. That's right, so what? It would swallow you and me and the world too. And the rest of the solar system. Proxima Centauri is looking a bit nervous as well.

Post Reply