Page 1 of 1

imbricate & repeat

Posted: Thu Jul 05, 2012 1:26 am
by Krynn
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

Re: imbricate & repeat

Posted: Thu Jul 05, 2012 5:21 am
by dunbarx
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

Re: imbricate & repeat

Posted: Thu Jul 05, 2012 11:22 am
by Krynn
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

Re: imbricate & repeat

Posted: Fri Jul 06, 2012 5:08 am
by dunbarx
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

Re: imbricate & repeat

Posted: Fri Jul 06, 2012 5:52 am
by dunbarx
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