Page 1 of 1

matching 2 variables in repeat loop

Posted: Sat Jul 12, 2014 4:02 pm
by gpearson
In previous version of livecode up to 6.6.1 the following code used to work in my project but now that I updated to 6.6.2 it does not.

Code: Select all

repeat for each line L in tFiles
 if L contains gMainProgramArchiveName then
    put true into tMainAppDownload
  end if
end repeat
The value of tFiles is a directory listing of the programs storage directory that I use and if it contains the livecode program stack then I do not want to download it again from the website and run the currently downloaded file.

In version 6.6.2, I get an error on the contains line that reads:
stack "TruckersWalletSplashScreen": compilation error at line 185 {Expression: unquoted literal), char 27

Line 185 is the line that has if L contains


This has been a great learning assignment for me but hope one day I can get this application released soon.

Re: matching 2 variables in repeat loop

Posted: Sat Jul 12, 2014 8:31 pm
by Simon
Hi Graham,
I just tried this in 6.6.1 and 6.6.2 and it is working;

Code: Select all

on mouseUp
   answer folder "pick a darn folder"
   set the defaultFolder to it
   put the files into tFiles
   put ".livecode" into gMainProgramArchiveName
   repeat for each line L in tFiles
      if L contains gMainProgramArchiveName then
         put true into tMainAppDownload
      end if
   end repeat
end mouseUp
Isn't that the same as you are doing?

But I can see what liveCode is complaining about it thinks "gMainProgramArchiveName" is a string not a variable.

Simon

Re: matching 2 variables in repeat loop

Posted: Sat Jul 12, 2014 9:21 pm
by dunbarx
Hi.

I am sure Simon is on to something. Does it help to know that LC will try to evaluate an unquoted literal as a variable name first? And that if it finds no variable by that name, it will, as an accommodation to the programmer, try to use that string as if it was a quoted literal?

This leads to conflicts all the time. Please make sure that this possible conflict is NOT your issue.

Craig Newman