imbricate & repeat

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
Krynn
Posts: 10
Joined: Thu Jul 05, 2012 1:11 am

imbricate & repeat

Post by Krynn » Thu Jul 05, 2012 1:26 am

Hello,

I want to nest loops (repeat). But I do not know how to avoid repeat of 10x

I have to search a list "a, b​​, c, d, e, f, g, ..."
but the devices may be called:
"a.log"
"b.log"
"c.log"
"d.log"
"aa.log"
"ab.log"
"ac.log"
"bba.log"
....

Code: Select all

put "a,b,c,d,e,,,,,," into ListeItem
repeat with x = 1 to the number of items of ListeItem
put x & ".log" after fld "info"
.....
end repet

How cleanly, saying that when the first repeat loop is finished. It should add a 2nd digit and so on up to 10 without impriquer 10 repeat.

And sorry for my question from beginner
thank you
Krynn

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9665
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: imbricate & repeat

Post by dunbarx » Thu Jul 05, 2012 5:21 am

Hi.

Are you saying that all ten-char combinations of 26 letters are possible? That is 26^10, or 141 trillion combinations.

Do I have this right?

Craig Newman

Krynn
Posts: 10
Joined: Thu Jul 05, 2012 1:11 am

Re: imbricate & repeat

Post by Krynn » Thu Jul 05, 2012 11:22 am

Hello

No, I will not go as far as ca. This is the principle.
I should stop to 5 digits.

This is how to proceed me to update.

Bests regards
Krynn

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9665
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: imbricate & repeat

Post by dunbarx » Fri Jul 06, 2012 5:08 am

Krynn

Still not understanding the scope of the possible combinations.

You say no more than five letters, But you also say that "ca" is the limit. Please try to confirm.

To write a script to give all combinations of letters is simple. I just need to know how far to go.

Craig Newman

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9665
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: imbricate & repeat

Post by dunbarx » Fri Jul 06, 2012 5:52 am

I made a short script to create letter combinations. You must have a field "results" to see the product.

I ran this script up to three letter strings. If you see my method, you can see how to extend it to any length. I still am not sure of the overall scope of your combination needs. Anyway, in a button script:

Code: Select all

on mouseUp
   put "" into fld "results"
   put "abcdefghijklmnopqrstuvwxyz" into pool
   
   repeat with y = 1 to 26
      put char y of pool & ".log" into line y of temp
   end repeat
   put return after temp

   repeat with a = 1 to 26
      repeat with b = 1 to 26
         put char a of pool & char b of pool & ".log" & return after temp
      end repeat
   end repeat
   put return after temp

   repeat with a = 1 to 26
      repeat with b = 1 to 26
         repeat with c = 1 to 26
            put char a of pool & char b of pool & char c of pool & ".log" & return after temp
         end repeat
      end repeat
   end repeat
   
   put temp into fld  "results"
end mouseUp
Write back if this is not what you needed.

Craig Newman

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”