Re: [Gambas-user] A random sort of listview

2009-04-14 Thread Doriano Blengino
jbskaggs ha scritto: > It is Gambas related! Where else are noobs like me going to learn this? > > Please continue as you are both teaching me Maestros! To stop now would be > like taking candy from a baby just after the wrapper was opened. > Thanks for your appreciation words. What Dominique

Re: [Gambas-user] A random sort of listview

2009-04-13 Thread jbskaggs
It is Gambas related! Where else are noobs like me going to learn this? Please continue as you are both teaching me Maestros! To stop now would be like taking candy from a baby just after the wrapper was opened. JB SKaggs Simonart Dominique wrote: > > Hi Doriano, > > > I agree to everyth

Re: [Gambas-user] A random sort of listview

2009-04-13 Thread Simonart Dominique
Hi Doriano, > I agree to everything you wrote. I thought the same about what you wrote! :) >... Then, recalling to my mind >the way a person shuffles cards by hand, I tried to express another >algorithm, which in a certain way lets you to adjust the randomness: a >person can shuffle very

Re: [Gambas-user] A random sort of listview

2009-04-12 Thread Doriano Blengino
Dominique SIMONART ha scritto: > Doriano Blengino a écrit : > >> jbskaggs ha scritto: >> >> > FOR i = 0 TO ListView1.count - 1 STEP 1 > myArray[i] = i > NEXT > > FOR i = ListView1.count - 1 TO 0 STEP -1 > a = Int(Rnd(i + 1)) > SWAP myArray[i], myArray[a] >>

Re: [Gambas-user] A random sort of listview

2009-04-12 Thread Dominique SIMONART
Doriano Blengino a écrit : > jbskaggs ha scritto: > FOR i = 0 TO ListView1.count - 1 STEP 1 myArray[i] = i NEXT FOR i = ListView1.count - 1 TO 0 STEP -1 a = Int(Rnd(i + 1)) SWAP myArray[i], myArray[a] PRINT i, a NEXT > Ap

Re: [Gambas-user] A random sort of listview

2009-04-12 Thread Dominique SIMONART
-- This SF.net email is sponsored by: High Quality Requirements in a Collaborative Environment. Download a free trial of Rational Requirements Composer Now! http://p.sf.net/sfu/www-ibm-com _

Re: [Gambas-user] A random sort of listview

2009-04-12 Thread jbskaggs
You were correct! There was a extra comma in the data file that was breaking the loop! BTW to you an everyone else if you celebrate it, Happy Easter! If not ignore me. ;) JB SKaggs Simonart Dominique wrote: > > Hi again :) > > May be you did not see the last sentence of my answer wich > is

Re: [Gambas-user] A random sort of listview

2009-04-12 Thread jbskaggs
This works much better at getting a more shuffled list! Thanks Doriano Blengino wrote: > > jbskaggs ha scritto: >> FOR i = 0 TO ListView1.count - 1 STEP 1 myArray[i] = i NEXT FOR i = ListView1.count - 1 TO 0 STEP -1 a = Int(Rnd(i + 1)) SWAP myArray[i], my

Re: [Gambas-user] A random sort of listview

2009-04-12 Thread Simonart Dominique
Hi again :) May be you did not see the last sentence of my answer wich is written in 3 places? Your code is just fine and I don't have any problem with the ListViews. Of course, I had to initialize the ListView1 with my own data like this: FOR i = 0 to 21 ListView1.Add(Str(i), "number " &

Re: [Gambas-user] A random sort of listview

2009-04-12 Thread Doriano Blengino
jbskaggs ha scritto: > >>> FOR i = 0 TO ListView1.count - 1 STEP 1 >>> myArray[i] = i >>> NEXT >>> >>> FOR i = ListView1.count - 1 TO 0 STEP -1 >>> a = Int(Rnd(i + 1)) >>> SWAP myArray[i], myArray[a] >>> PRINT i, a >>> NEXT >>> Apart from the problem of missing records, there could be al

Re: [Gambas-user] A random sort of listview

2009-04-11 Thread jbskaggs
Hi yourself! Here is the problem in the code: FOR i = 0 TO ListView1.Count - 1 ' write items in listview2 TRY PRINT myArray[i] listview1.MoveTo(myArray[i]) TRY c = listview1.Item.Key TRY PRINT myArray[i], "listview1.item.key ", c, " counter i: ", i, " total count: ", listview1.Count TRY listview

Re: [Gambas-user] A random sort of listview

2009-04-11 Thread Simonart Dominique
Hi, jbskaggs a écrit : > Okay I thought this was worked out but its still not working- I always end up > losing the last two list items. > > Here is the console output from my print statements: > This first list is printing i, a from this command SWAP myArray[i], > myArray[a] > > 21 21 > 20

Re: [Gambas-user] A random sort of listview

2009-04-11 Thread jbskaggs
Okay I thought this was worked out but its still not working- I always end up losing the last two list items. Here is the console output from my print statements: This first list is printing i, a from this command SWAP myArray[i], myArray[a] 21 21 20 13 19 0 18 13 17 11

Re: [Gambas-user] A random sort of listview

2009-04-08 Thread Simonart Dominique
Hi Jussi, NO, there is no bug, it's my mistake!! I listed the myArray values just after the SWAP instruction. But, as you can see it in a preceeding answer to jbskaggs, this is a bad idea because in the "forward FOR NEXT loop" case, these values could change any time. You don't make this error

Re: [Gambas-user] A random sort of listview

2009-04-08 Thread Jussi Lahtinen
Hi! I can't reproduce your problem. Randomize with seed 12345, I got; >From 0 to 9: 4 0 7 9 5 1 2 6 3 8 >From 9 to 0: 4 2 7 8 3 0 6 9 1 5 Both correct. So maybe there is a bug in SWAP command with Gambas version... what are you using? With Gambas 2.10 it is working. Jussi P.S. Code I used to

Re: [Gambas-user] A random sort of listview

2009-04-07 Thread Simonart Dominique
Hi, jbskaggs a écrit : > Okay, > > But why does it do that? I don't see why the direction should matter what > am I missing ? Becuase maybe this is something that has plagued me and > caused me headaches for a while. > > JB Skaggs > You're right! Thanks! My mistake is that I listed the myArr

Re: [Gambas-user] A random sort of listview

2009-04-07 Thread jbskaggs
Okay, But why does it do that? I don't see why the direction should matter what am I missing ? Becuase maybe this is something that has plagued me and caused me headaches for a while. JB Skaggs Simonart Dominique wrote: > > Hi, > > jbskaggs a écrit : >> When I ran the code it ran fine- w

Re: [Gambas-user] A random sort of listview

2009-04-07 Thread Simonart Dominique
Hi, jbskaggs a écrit : > When I ran the code it ran fine- why is it important to have it count > backwards in the random swap? > > ie for i =199 to 0 step -1 instead of for i=0 to 199 step 1? > > JB SKaggs > Strange, because it should not :) run a test with 10 numbers 0-9 and fixe the seed wi

Re: [Gambas-user] A random sort of listview

2009-04-07 Thread jbskaggs
When I ran the code it ran fine- why is it important to have it count backwards in the random swap? ie for i =199 to 0 step -1 instead of for i=0 to 199 step 1? JB SKaggs Simonart Dominique wrote: > > Hi, > > Hmm, did you run exactly this code? If so, there is > something wrong with the se

Re: [Gambas-user] A random sort of listview

2009-04-07 Thread Simonart Dominique
Simonart Dominique a écrit : > Hi, > > Hmm, did you run exactly this code? If so, there is > something wrong with the second FOR NEXT loop > > jbskaggs a écrit : >> using your suggestions and the swap command vs manual swapping this is my >> code: >> >> public b as string 'optional string used

Re: [Gambas-user] A random sort of listview

2009-04-07 Thread Simonart Dominique
Hi, Hmm, did you run exactly this code? If so, there is something wrong with the second FOR NEXT loop jbskaggs a écrit : > using your suggestions and the swap command vs manual swapping this is my > code: > > public b as string 'optional string used to hold the array data for file or > split l

Re: [Gambas-user] A random sort of listview

2009-04-06 Thread jbskaggs
using your suggestions and the swap command vs manual swapping this is my code: public b as string 'optional string used to hold the array data for file or split later PUBLIC SUB button4_click() ' initialize array DIM myArray AS Integer[200] DIM a AS Integer DIM i AS Integer FOR i = 0 TO 199 S

Re: [Gambas-user] A random sort of listview

2009-04-06 Thread Simonart Dominique
Simonart Dominique a écrit : > jbskaggs a écrit : >> I came up with a way to random sort listview. (Iuse this for random >> shuffling card slots on games) But it isnt efficient some pointers if you >> dont mind? >> >> I use two listviews one to sort from and one to sort to: >> >> I first copy all

Re: [Gambas-user] A random sort of listview

2009-04-06 Thread Simonart Dominique
jbskaggs a écrit : > > I came up with a way to random sort listview. (Iuse this for random > shuffling card slots on games) But it isnt efficient some pointers if you > dont mind? > > I use two listviews one to sort from and one to sort to: > > I first copy all the listitems from list 1 to list

[Gambas-user] A random sort of listview

2009-04-06 Thread jbskaggs
I came up with a way to random sort listview. (Iuse this for random shuffling card slots on games) But it isnt efficient some pointers if you dont mind? I use two listviews one to sort from and one to sort to: I first copy all the listitems from list 1 to list 2 EXCEPT the key for listview2 ite