matching 2 variables in repeat loop

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
gpearson
Posts: 84
Joined: Wed Feb 03, 2010 12:55 pm

matching 2 variables in repeat loop

Post by gpearson » Sat Jul 12, 2014 4:02 pm

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.
---
Graham Pearson
Goshen, IN USA

We Are Closed Today is your single internet resource for Indiana Area School Closings, Visit http://www.weareclosedtoday.com

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

Re: matching 2 variables in repeat loop

Post by Simon » Sat Jul 12, 2014 8:31 pm

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
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

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

Re: matching 2 variables in repeat loop

Post by dunbarx » Sat Jul 12, 2014 9:21 pm

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

Post Reply