Re: repeat with i=

2011-07-15 Thread J. Landman Gay
On 7/15/11 6:02 PM, Roger Eller wrote: On Fri, Jul 15, 2011 at 6:56 PM, Pete wrote: Sounds like the best solution. Thanks for posting the question - I learned about "delete", "any", and more about "sort"! Pete Molly's Revenge These little challenges are great f

Re: repeat with i=

2011-07-15 Thread Roger Eller
On Fri, Jul 15, 2011 at 6:56 PM, Pete wrote: > Sounds like the best solution. Thanks for posting the question - I learned > about "delete", "any", and more about "sort"! > Pete > Molly's Revenge > These little challenges are great for the LC community. I learn som

Re: repeat with i=

2011-07-15 Thread Pete
othymiller.com> wrote: > Thanks for all the suggestions. > > I think I'll go with: > > on mouseUp > local theNums > put "1,2,3,4,5,6" into theNums > sort items of theNums numeric by random(100) > repeat with i = 1 to 6 >do "whatever"

Re: repeat with i=

2011-07-15 Thread Timothy Miller
Thanks for all the suggestions. I think I'll go with: on mouseUp local theNums put "1,2,3,4,5,6" into theNums sort items of theNums numeric by random(100) repeat with i = 1 to 6 do "whatever" & item i of theNums end repeat end mouseUp T

Re: repeat with i=

2011-07-15 Thread James Hurley
> -- > > Message: 7 > Date: Thu, 14 Jul 2011 10:06:01 -0500 > From: Ronald Zellner > To: use-livecode@lists.runrev.com > Subject: Re: repeat with i= > Message-ID: > Content-Type: text/plain; charset=us-ascii > > Jim's seems

Re: repeat with i=

2011-07-14 Thread Jerry J
Works in the message box. On Jul 14, 2011, at 4:11 PM, Pete wrote: > No problem. I'd definitely try it though - I've been bitten before by the > docs saying things that weren't quite true! > Pete > Molly's Revenge > > > > > On Thu, Jul 14, 2011 at 3:58 PM, Jerr

Re: repeat with i=

2011-07-14 Thread Pete
No problem. I'd definitely try it though - I've been bitten before by the docs saying things that weren't quite true! Pete Molly's Revenge On Thu, Jul 14, 2011 at 3:58 PM, Jerry J wrote: > Aha! The docs say so! Learned something new today. > > Thanks Pete, > Je

Re: repeat with i=

2011-07-14 Thread Jerry J
Aha! The docs say so! Learned something new today. Thanks Pete, Jerry On Jul 14, 2011, at 3:51 PM, Pete wrote: > Doesn't setting the wholematches to true deal with this? > Pete > Molly's Revenge > > > > > On Thu, Jul 14, 2011 at 3:35 PM, Jerry J wrote: > >> O

Re: repeat with i=

2011-07-14 Thread Pete
Doesn't setting the wholematches to true deal with this? Pete Molly's Revenge On Thu, Jul 14, 2011 at 3:35 PM, Jerry J wrote: > On Jul 14, 2011, at 2:12 AM, Keith Clarke wrote: > > > ...ah yes, of course, thanks Jim - I forgot that 'delete item y' is not > the s

Re: repeat with i=

2011-07-14 Thread Jerry J
On Jul 14, 2011, at 2:12 AM, Keith Clarke wrote: > ...ah yes, of course, thanks Jim - I forgot that 'delete item y' is not the > same as 'delete item *called* y' ! > > So, would itemoffset help...? > > put "1,2,3,4,5,6" into theNumbers > repeat until theNumbers is empty > put any item the

Re: repeat with i=

2011-07-14 Thread James Hurley
I haven't been following this thread so my apologies if I'm missing the point, but a while back I had to deal with the task of selecting m random people for a voter pole from a list N registered voters, where N was over 100,000. Check out "Random pick" in Rev Online. I found using an array 3 tim

Re: repeat with i=

2011-07-14 Thread J. Landman Gay
On 7/14/11 10:06 AM, Ronald Zellner wrote: Jim's seems to be the most efficient and accurate, I agree. Sorting the list before the loop and then peeling off the items one by one is the most efficient way to do it. I mentioned "any" because it's such a nice addition to the language, but I didn

Re: repeat with i=

2011-07-14 Thread Klaus on-rev
Hi Ron, Am 14.07.2011 um 17:06 schrieb Ronald Zellner: > Jim's seems to be the most efficient and accurate, > but I needed this change to make it work. ' of ' changed to 'in' > > I like to add something to create quick feedback- like the field "chosen". > Easier to see the result. > Then switch

Re: repeat with i=

2011-07-14 Thread Keith Clarke
Ronald, Sorry, don't use my first attempt - it had an error. You'd need the updated version that used itemoffset to delete the the specific number in the list, rather than it's position. To see what was used in each loop in real time, you can either put y or answer y To see the choices made retr

Re: repeat with i=

2011-07-14 Thread Ronald Zellner
Jim's seems to be the most efficient and accurate, but I needed this change to make it work. ' of ' changed to 'in' I like to add something to create quick feedback- like the field "chosen". Easier to see the result. Then switch to the complete function when the code is working. on mouseUp lo

Re: repeat with i=

2011-07-14 Thread Jim Ault
On Jul 14, 2011, at 2:12 AM, Keith Clarke wrote: ...ah yes, of course, thanks Jim - I forgot that 'delete item y' is not the same as 'delete item *called* y' ! So, would itemoffset help...? put "1,2,3,4,5,6" into theNumbers repeat until theNumbers is empty put any item theNumbers in

Re: repeat with i=

2011-07-14 Thread paolo mazza
Tha's interesting. I think you have to use delete.. of instead delete from . To me this is correct. put "1,2,3,4,5,6" into theNumbers repeat until theNumbers is empty put any item theNumbers into n put n after theNumberList delete item (itemOffset(n, theNumbers)) of t

Re: repeat with i=

2011-07-14 Thread Keith Clarke
...ah yes, of course, thanks Jim - I forgot that 'delete item y' is not the same as 'delete item *called* y' ! So, would itemoffset help...? put "1,2,3,4,5,6" into theNumbers repeat until theNumbers is empty put any item theNumbers into n do something delete (itemOffset(n

Re: repeat with i=

2011-07-14 Thread Jim Ault
On Jul 14, 2011, at 12:05 AM, Keith Clarke wrote: ...so for a random selection, enforcing the use of all 6 items, would this work? put "1,2,3,4,5,6" into x repeat until x is empty put any item of x into y do something delete item y from x end repeat No, since the

Re: repeat with i=

2011-07-14 Thread Keith Clarke
...so for a random selection, enforcing the use of all 6 items, would this work? put "1,2,3,4,5,6" into x repeat until x is empty put any item of x into y do something delete item y from x end repeat Best, Keith.. On 14 Jul 2011, at 05:58, J. Landman Gay wrote: > On 7/1

Re: repeat with i=

2011-07-13 Thread Scott Morrow
Cool, I didn't know about "any". Thanks, Jacque! Scott Morrow On Jul 13, 2011, at 9:58 PM, J. Landman Gay wrote: > On 7/13/11 11:33 PM, Pete wrote: >> You're right, should probably be something like "replace y& comma with >> empty in x". > > Plain old "delete" does it. > > Also, not everyon

Re: repeat with i=

2011-07-13 Thread Pete
Great, learned two things form this - delete and any! Pete Molly's Revenge On Wed, Jul 13, 2011 at 9:58 PM, J. Landman Gay wrote: > On 7/13/11 11:33 PM, Pete wrote: > >> You're right, should probably be something like "replace y& comma with >> empty in x". >> >

Re: repeat with i=

2011-07-13 Thread J. Landman Gay
On 7/13/11 11:33 PM, Pete wrote: You're right, should probably be something like "replace y& comma with empty in x". Plain old "delete" does it. Also, not everyone knows about the "any" keyword but it's really handy for lines like this: put item random(the number of items in x) of x into

Re: repeat with i=

2011-07-13 Thread Pete
;d change the > "put empty" line to "delete item y of x". I think the put empty would just > put "" into that item, but the item would still be there, like: 1,2,,4,5,6 > > ~ Chris Innanen > ~ Nonsanity > > > On Wed, Jul 13, 2011 at 9:25 P

Re: repeat with i=

2011-07-13 Thread Dick Kriesel
On Jul 13, 2011, at 7:53 PM, Nonsanity wrote: > I like Pete's best - closest to what I was thinking - I like Jerry's best - it's better than I was thinking ... Jerry's is less code executed less often: one statement once versus two statements for each item. -- Dick _

Re: repeat with i=

2011-07-13 Thread Nonsanity
On Wed, Jul 13, 2011 at 9:25 PM, Pete wrote: > Maybe (untested): > > put "1,2,3,4,5,6" into x > repeat with i=1 to 6 > put item random(the number of items in x) into y > > put empty into item y of x > end repeat > > Pete > Molly's Revenge

Re: repeat with i=

2011-07-13 Thread Roger Eller
This one guarantees that each of the 6 random numbers is only used once. put "1,2,3,4,5,6" into x replace comma with cr in x repeat until (the number of lines of t) = 6 -- be cautious with until loops put random(6) into tLine if tLine is not among the lines of t then put (line

Re: repeat with i=

2011-07-13 Thread Jerry J
On Jul 13, 2011, at 6:01 PM, Timothy Miller wrote: > Hi, > > Let's say that I want to do something like > > repeat with i = 1 to 6 > do "whatever" & i > end repeat > > Except, I want 1 to 6 to be in random sequence > > I could think of a

Re: repeat with i=

2011-07-13 Thread Pete
Maybe (untested): put "1,2,3,4,5,6" into x repeat with i=1 to 6 put item random(the number of items in x) into y put empty into item y of x end repeat Pete Molly's Revenge <http://www.mollysrevenge.com> On Wed, Jul 13, 2011 at 6:01 PM, Timothy Miller < gand...

Re: repeat with i=

2011-07-13 Thread Roger Eller
On Wed, Jul 13, 2011 at 9:01 PM, Timothy Miller wrote: > Hi, > > Let's say that I want to do something like > > repeat with i = 1 to 6 > do "whatever" & i > end repeat > > Except, I want 1 to 6 to be in random sequence > > I could think of a

repeat with i=

2011-07-13 Thread Timothy Miller
Hi, Let's say that I want to do something like repeat with i = 1 to 6 do "whatever" & i end repeat Except, I want 1 to 6 to be in random sequence I could think of a few kludgy ways to do this. Is there a standard approach? A simple approach? Than