Difficulty finding problem in If, Else If 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
pink
Posts: 280
Joined: Wed Mar 12, 2014 6:18 pm

Difficulty finding problem in If, Else If repeat loop

Post by pink » Tue May 13, 2014 5:47 pm

this little program processes a large email list and takes out blank emails, duplicates, opt-outs and people who are on "hiatus"; counts are created so that each record can be accounted for to my client (this is repeated among many markets

here is my current code, everything is working correctly except the else if line which checks to see if someone is on hiatus:

Code: Select all

     repeat for each line listLine in field "buffalonew"
          add 1 to field "bufStart"
          if "@" is not in item 1 of listLine then
               add 1 to field "bufBlank"
          else if item 1 of listLine is among the lines of field "buffalo" on card "data" then
               add 1 to field "bufDup"
          else
               put item 1 of listLine & return after field "buffalo" on card "data"
               if item 1 of listLine is among the lines of field "optouts" on card "data" then
                    add 1 to field "bufOptout"
               else if item 1 of listLine is among the lines of field "hiatus" on card "data" then
                    add 1 to field "bufHiatus"
               else
                    put listLine & return after the field "buffaloout"
                    add 1 to field "bufSend"
               end if
          end if
     end repeat
here was my original code, this does work, I'm just trying to make something less ugly...

Code: Select all

repeat for each line listLine in field "buffalonew"
      add 1 to field "bufStart"
	if item 1 of listLine contains "@" then
      put listLine & return after the field "buffaloout"
   else 
      add 1 to field "bufBlank"
   end if
end repeat

put field "buffaloout" into field "buffalonew"
put empty into field "buffaloout"

repeat for each line listLine in field "buffalonew"
   if item 1 of listLine is not among the lines of field "buffalo" on card "data" then
   put item 1 of listLine & return after  field "buffalo" on card "data"
   put listLine & return after the field "buffaloout"
else
   add 1 to field "bufDup"
   end if
end repeat

put field "buffaloout" into field "buffalonew"
put empty into field "buffaloout"

repeat for each line listLine in field "buffalonew"
   if item 1 of listLine is not among the lines of field "optouts" on card "data" then
      put listLine & return after the field "buffaloout"          
   else
      add 1 to field "bufOptout"
   end if
end Repeat

put field "buffaloout" into field "buffalonew"
put empty into field "buffaloout"

repeat for each line listLine in field "buffalonew"
   if item 1 of listLine is not among the lines of field "hiatus" on card "data" then
      put listLine & return after the field "buffaloout"       
      put item 1 of listLine & return after  field "buffalo" on card "data"
      add 1 to field "bufSend"   
   else
      add 1 to field "bufHiatus"
   end if
end Repeat

Greg (pink) Miller

MadPink, LLC
I'm Mad, Pink and Dangerous to Know

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: Difficulty finding problem in If, Else If repeat loop

Post by Mark » Wed May 14, 2014 2:26 pm

Hi,

You write that the "else if" doesn't work but you don't tell which one of the two "else-if" lines this would be and you don't say what it does and what it should do instead.

Kind regards,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

pink
Posts: 280
Joined: Wed Mar 12, 2014 6:18 pm

Re: Difficulty finding problem in If, Else If repeat loop

Post by pink » Wed May 14, 2014 2:35 pm

it is the else if line related to "hiatus"

specifically here:

Code: Select all

               else if item 1 of listLine is among the lines of field "hiatus" on card "data" then
                    add 1 to field "bufHiatus"
item 1 is an email address, and "hiatus" is a big lilst of email addresses, so if the email address being looked at is in "hiatus," then the counter should be incremented and that's it, nothing happens with the record

instead, the program is continuing to the else statement and putting the record into "buffaloout" which is the list to be emailed out
Greg (pink) Miller

MadPink, LLC
I'm Mad, Pink and Dangerous to Know

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: Difficulty finding problem in If, Else If repeat loop

Post by Mark » Wed May 14, 2014 2:46 pm

Hi,

I think that you have e-mail addresses that are in field "hiatus" as well as in other fields. Probably, you need to change the conditions like this:

Code: Select all

else if item 1 of listLine is among the lines of field "buffalo" on card "data" and item 1 of listLine is not among the lines of field "hiatus" of cd "data" then
You need to add this to all relevant if-then-else statements.

Does that help?

Kind regards,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

robertem
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 25
Joined: Tue Mar 19, 2013 2:58 pm

Re: Difficulty finding problem in If, Else If repeat loop

Post by robertem » Wed May 14, 2014 6:45 pm

I agree, that code works for me.

Could the addresses in "hiatus" also be in "optouts"?

My guess is you have the counts there to debug, if that is the case, you could combine those 2 statements as Mark suggests and it should work.

Post Reply