Re: [Gambas-user] A random sort of listview
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] PRINT i, a NEXT Apart from the problem of missing records, there could be also a randomness problem in the algorithm... I am really not sure, but it seems that certain slots have more chances to be swapped than other - myarray[0] can be swapped COUNT times, while myarray[count-1] gets only a chance. I am not sure of what this signifies: it is true that the swap affects the values contained in slots, and not the slots themselves, but anyway there could be another method. One could also do this: for i = 0 to 1000 ' arbitrary value, large enough (100?) c1 = int(rnd(listview1.count)) c2 = int(rnd(listview1.count)) swap myarray[c1], myarray[c2] next This way, every slot gets the same chances to be swapped; for sufficient loops, it should make a good job... perhaps more random than before. And perhaps, as the algorthm is different, it could solve the problem of missing records (which I didn't understand...). Cheers, = I resend my message because it seems the text is missing?! :-\ This is not really a problem. The Randomizing process could be explained like this: 1) You align a sorted card deck in front of you on a table 2) then, from all the cards on the table you take a random card in your hand so there is a place without card on the table 3) you put the last card on the table in this hole, so the hole is now at the last place 4) you continue by returning to 2 until you got all the cards in your hand Now you have a randomized deck of cards in your hand 5) you put the first card you got in the last place on the table and continue to do that until you have no card in your hand. Now the randomized deck of cards is on the table. If you examine carefully this process, you will remark that each time you filled a hole with the last remaining card on the table, you could place the card you got just before in the last place, because it is free! You only have to remember to not take these cards already selected. So you could do the 5) between 3) and 4) and this is exactly which is done by the SWAP instruction! It is true that some places will be selected several times, but their content change each time (there is another card on these places each time). In no way you could loose a card in this process!!. The JBskaggs' problem, I think, is that, before he starts the process, there are twice 2 identical cards in his deck and Gambas does not admit that, so when Gambas encounters the duplicated cards it reject them, (but since TRY is used, you don't see the error!!) and finally, 2 cards are missing. Hope this is clearer :) I agree to everything you wrote. The first algorithm, the one you explain, is the more correct because with the minimum number of swaps you obtain a random sequence. It is equivalent to build another list based on the first, without using two lists, and you expressed it very well. Without analyzing too much, I said some slots get more chances than other, pointing out that the slots have different chances, and not the values inside the slots (which is different). 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 well, or not. But, thinking over, my algorithm does not fully respect this situation, because a true player shuffles cards in chunks, by taking the last part of a deck and scattering it in the middle of the remaining part... If someone wants to write a realistic card games, perhaps could consider this. Anyway, I repeat, you were right - the first algorithm is ok. Regards, -- Doriano Blengino Listen twice before you speak. This is why we have two ears, but only one mouth. -- 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 ___ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user
Re: [Gambas-user] Input box incorrect size of the text control. My first problem.
Hi, everybody! Excuse my English. I've noticed an embarrasing 'bug' when I use an Input Box in my programs. Functionality isn't put at risk but looks horrible. I think an image is better than words... http://www.nabble.com/file/p23013689/inputbox.png How can I fix this problem? It happens whatever computer is used. I think this is a bug in gb.gtk. To fix that at the moment, you can write your own InputBox. The source code of InputBox is in the gb.form component source code, so you can take it and modify it for your own use. I will look at it later. Regards, -- Benoît -- 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 ___ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user
[Gambas-user] Busy with theatre...
Hi, I will play at the festival du théâtre universitaire de Cabourg (academic theatre festival of Cabourg - http://www.cabourg.net/spip.php?article388), and so won't be in front of my computer between Wednesday, 15th and Sunday, 19th. There are two or three pending bugs, so people must be patient. If some french reader leaving near Cabourg read that, maybe he can come to see me. :-) The play is Les Justes, from Albert Camus. Regards, -- Benoît -- 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 ___ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user
Re: [Gambas-user] Busy with theatre...
Theatre and drama is hardwork- to do that and Gambas is impressive. Wish I could see the play - but Im stuck in Kansas. JB Bugzilla from gam...@users.sourceforge.net wrote: Hi, I will play at the festival du théâtre universitaire de Cabourg (academic theatre festival of Cabourg - http://www.cabourg.net/spip.php?article388), and so won't be in front of my computer between Wednesday, 15th and Sunday, 19th. There are two or three pending bugs, so people must be patient. If some french reader leaving near Cabourg read that, maybe he can come to see me. :-) The play is Les Justes, from Albert Camus. Regards, -- Benoît -- 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 ___ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user -- View this message in context: http://www.nabble.com/Busy-with-theatre...-tp23019427p23019892.html Sent from the gambas-user mailing list archive at Nabble.com. -- 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 ___ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user
Re: [Gambas-user] Busy with theatre...
Good luck with the play 2009/4/13 jbskaggs jbska...@skaggsworld.com Theatre and drama is hardwork- to do that and Gambas is impressive. Wish I could see the play - but Im stuck in Kansas. JB Bugzilla from gam...@users.sourceforge.net wrote: Hi, I will play at the festival du théâtre universitaire de Cabourg (academic theatre festival of Cabourg - http://www.cabourg.net/spip.php?article388 ), and so won't be in front of my computer between Wednesday, 15th and Sunday, 19th. There are two or three pending bugs, so people must be patient. If some french reader leaving near Cabourg read that, maybe he can come to see me. :-) The play is Les Justes, from Albert Camus. Regards, -- Benoît -- 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 ___ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user -- View this message in context: http://www.nabble.com/Busy-with-theatre...-tp23019427p23019892.html Sent from the gambas-user mailing list archive at Nabble.com. -- 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 ___ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user -- 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 ___ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user
Re: [Gambas-user] shared librarry into gambas
Thanks a lot man... This certainly helps. I'll see if I can follow your example into making something useful with libparted. I found the API references here http://www.gnu.org/software/parted/api/modules.html -- 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 ___ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user
Re: [Gambas-user] A random sort of listview
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 well, or not. But, thinking over, my algorithm does not fully respect this situation, because a true player shuffles cards in chunks, by taking the last part of a deck and scattering it in the middle of the remaining part... If someone wants to write a realistic card games, perhaps could consider this. It could be interesting to define a sort of randomness evaluation, so we could compare several methods or evaluate the efficient limit to use. For exemple, you take 1000 in your method but may be 500 will be enough? I will take a 10 cards' deck as illustration I could think about 2 criters: 1) absolute difference between the initial and the final positions 2) absolute difference between 2 adjacent items The first criter is not fair because all the places are not equivalent! the 5th position could not exceed a 5 difference but the 0th position could be 9! So we have to consider the serie 0-9 as a ring were 0 is next to 9, so the maximum difference is 5. The same could be said about the second criter! Now, I will stop to talk about that because it's no more Gambas related :( cheers 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 ___ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user
Re: [Gambas-user] In Plain English- A definition of the Datatypes please?
Hi! For me, because of my experience, documentation of datatypes is self evident. I think you should be more precise with your question. What you don't understand? Short, integer and long are pretty much all same thing, but they can hold different maximum (and minimum [negative]) values. Short, integer and long can contain only whole number, so example 3.1415 cannot be stored to integer type variable. Byte is like above, but it can't contain negative values. Byte is also used as size unit, because it always means 8 bit (bit means one state, which can be 1 or 0 [ see: http://en.wikipedia.org/wiki/Binary_numeral_system ]). So, if you need to store value of Pi, you need float type of variable. These are single and float. They are different not only for maximum values, but with accuracy to describe given value. See http://en.wikipedia.org/wiki/Floating_point . Rest are basically just different amount of bits too... but you need more deep understanding of computers. For this moment I can't figure how to explain concepts like pointers with simple terms. You must study. Wikipedia and google is your friend. Hope that helps! Jussi On Fri, Apr 10, 2009 at 08:10, jbskaggs jbska...@skaggsworld.com wrote: Earlier this week I was given an excellent definition oh Hungarian Convetion naming ie the h in hObjects. Could someone either point me to a resource in plain English or explain to me in plain English the Datatypes? Integer Long Short Array etc... this is what I found on the documentation: Datatype Description Default value Size in memory Boolean True or false. FALSE 1 byte Byte 0...255 0 1 byte Short -32.768...+32.767 0 2 bytes Integer -2.147.483.648...+2.147.483.647 0 4 bytes Long -9.223.372.036.854.775.808...+9.223.372.036.854.775.807 0 8 bytes Single Like the float datatype in C. 0.0 4 bytes Float Like the double datatype in C. 0.0 8 bytes Date Date and time, each stored in an integer. NULL 8 bytes String A variable length string of characters. NULL 4 bytes Variant Any datatype. NULL 12 bytes Object Anonymous reference to any object. NULL 4 bytes Pointer A memory address. 0 4 bytes on 32 bits systems, 8 bytes on 64 bits systems. For a novice like me I have made assumptions for the past year that turned out to be wrong and I would like to make sure I grasp what this is saying and not assume I do. Thanks JB -- View this message in context: http://www.nabble.com/In-Plain-English--A-definition-of-the-Datatypes-please--tp22983213p22983213.html Sent from the gambas-user mailing list archive at Nabble.com. -- 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 ___ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user -- 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 ___ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user
Re: [Gambas-user] A random sort of listview
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 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 well, or not. But, thinking over, my algorithm does not fully respect this situation, because a true player shuffles cards in chunks, by taking the last part of a deck and scattering it in the middle of the remaining part... If someone wants to write a realistic card games, perhaps could consider this. It could be interesting to define a sort of randomness evaluation, so we could compare several methods or evaluate the efficient limit to use. For exemple, you take 1000 in your method but may be 500 will be enough? I will take a 10 cards' deck as illustration I could think about 2 criters: 1) absolute difference between the initial and the final positions 2) absolute difference between 2 adjacent items The first criter is not fair because all the places are not equivalent! the 5th position could not exceed a 5 difference but the 0th position could be 9! So we have to consider the serie 0-9 as a ring were 0 is next to 9, so the maximum difference is 5. The same could be said about the second criter! Now, I will stop to talk about that because it's no more Gambas related :( cheers 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 ___ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user -- View this message in context: http://www.nabble.com/A-random-sort-of-listview-tp22919766p23027115.html Sent from the gambas-user mailing list archive at Nabble.com. -- 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 ___ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user
Re: [Gambas-user] X coordinate of a Form Frame. My Second Problem.
I wrote some code to center a Form window, even the Desktop Size is different. Here it is: FMain.X = Int((Desktop.Width - FMain.Width) / 2) FMain.Y = Int((Desktop.Height - FMain.Height) / 2) Meanwhile the Form is resized regarding to the Y coordinate, it doesn't work as well for the X coordinate. Why? It seems that FMain.X doesn't 'catch up' a number (FMain.X=100 won't work too) What's happening? Please, help me!!! :-) I tested a simple form with gb.gtk on KDE4, and everything seems to work as expected. Please: 1) Send your project. 2) Try with gb.qt to see the difference. 3) Check how your window manager moves newly opened windows. Regards, -- Benoît -- 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 ___ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user
Re: [Gambas-user] Input box incorrect size of the text control. My first problem.
Hi, everybody! Excuse my English. I've noticed an embarrasing 'bug' when I use an Input Box in my programs. Functionality isn't put at risk but looks horrible. I think an image is better than words... http://www.nabble.com/file/p23013689/inputbox.png How can I fix this problem? It happens whatever computer is used. I think this is a bug in gb.gtk. To fix that at the moment, you can write your own InputBox. The source code of InputBox is in the gb.form component source code, so you can take it and modify it for your own use. I will look at it later. Regards, I tested, and everything seems to be normal. Which version of Gambas do you use? -- Benoît -- 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 ___ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user