Re: [Gambas-user] A random sort of listview
-- 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
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 :) 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
[Gambas-user] How to know permanently the cursor coordinates in a gridview?
Hi, I've a main Gridview (grdGame) surrounded by 2 other grids, grdHdef on top and grdVdef on left of grdGame When the mouse cursor is over the main grid, I want to highlight a column of the top grid and a row of the left grid facing the cursor position. How to know at each instant where the cursor is, that is without action on any button? I cannot use Mouse.X/Y because there is no mouse event Thank for your help, -- Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA -OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise -Strategies to boost innovation and cut costs with open source participation -Receive a $600 discount off the registration fee with the source code: SFAD http://p.sf.net/sfu/XcvMzF8H ___ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user
Re: [Gambas-user] How to populate a gridview from keyboard (closed)
Please, consider this thread as closed as the subject is no mare relevant Dominique SIMONART a écrit : Benoît Minisini a écrit : Hi everyone, it seemed so simple that I feel a bit stupid with that question, but... I want to fill a gridview with text coming from the keyboard, as in a crossword. I think I've to deal with the keypress event and the key.text data, but how can I identify the cell to fill. I cannot even see any cursor on my grid. I want not to use the mouse cursor because my fingers are on the keyboard all the time. I wish to define the next cell with the cursor keys only. Could someone give me a short sample or point me on the right direction? Thanks in advance for your help Dominique Simonart Just implement the cursor your self. Create a class named MyGridView that inherits GridView. In it, create an observer on yourself to catch the KeyPress event, and add two class variables (let's name them $X and $Y) to store the cursor coordinates. Catch the Data event too to define the background / foreground of the cell: Color.SelectededBackground and Color.SelectedForeground for the current cell (Row = $Y and Column = $X), nothing otherwise (the standard colors). Then each time you move the cursor, update the $X and $Y variables, and refresh the old current cell and the new one. If you don't want to use the Data event, you must use the MyGridView[X, Y] cell accessor. Regards, Hi, I've implemented the Xcur, Ycur coordinates in a inherited class and this is working now. In case this could be used as an example, I join the little test (9.2K) here. Now I've another question. It is not related with the subject, but it is illustrated by the joined code, so I think I've to keep this thread open! My new question is: I want to execute some code while the mouse cursor is over a grid (the bottom right one in the joined piece). Note please that no mouse buttons are involved here, so I can't work whith the MouseMove event. The code don't concern the grid itself but the adjacent ones. I can't either use the GotFocus/LostFocus events because the code has to follow the mouse curso position as long the mouse cursor is over the grid. I hope this is clear enough ! thanks for your help, Dominique Simonart Dominique Simonart -- Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA -OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise -Strategies to boost innovation and cut costs with open source participation -Receive a $600 discount off the registration fee with the source code: SFAD http://p.sf.net/sfu/XcvMzF8H ___ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user
[Gambas-user] How to populate a gridview from keyboard
Hi everyone, it seemed so simple that I feel a bit stupid with that question, but... I want to fill a gridview with text coming from the keyboard, as in a crossword. I think I've to deal with the keypress event and the key.text data, but how can I identify the cell to fill. I cannot even see any cursor on my grid. I want not to use the mouse cursor because my fingers are on the keyboard all the time. I wish to define the next cell with the cursor keys only. Could someone give me a short sample or point me on the right direction? Thanks in advance for your help Dominique Simonart -- Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA -OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise -Strategies to boost innovation and cut costs with open source participation -Receive a $600 discount off the registration fee with the source code: SFAD http://p.sf.net/sfu/XcvMzF8H ___ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user
Re: [Gambas-user] How to populate a gridview from keyboard
Benoît Minisini a écrit : Hi everyone, it seemed so simple that I feel a bit stupid with that question, but... I want to fill a gridview with text coming from the keyboard, as in a crossword. I think I've to deal with the keypress event and the key.text data, but how can I identify the cell to fill. I cannot even see any cursor on my grid. I want not to use the mouse cursor because my fingers are on the keyboard all the time. I wish to define the next cell with the cursor keys only. Could someone give me a short sample or point me on the right direction? Thanks in advance for your help Dominique Simonart Just implement the cursor your self. Create a class named MyGridView that inherits GridView. In it, create an observer on yourself to catch the KeyPress event, and add two class variables (let's name them $X and $Y) to store the cursor coordinates. Catch the Data event too to define the background / foreground of the cell: Color.SelectededBackground and Color.SelectedForeground for the current cell (Row = $Y and Column = $X), nothing otherwise (the standard colors). Then each time you move the cursor, update the $X and $Y variables, and refresh the old current cell and the new one. If you don't want to use the Data event, you must use the MyGridView[X, Y] cell accessor. Regards, Thanks to all, Well Benoit, I think it's time for me to get inside all those inheritage, observer, etc. Learning is really the master keyword in programming! :) May be it's what keep us interested in! regards, Dominique Simonart -- Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA -OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise -Strategies to boost innovation and cut costs with open source participation -Receive a $600 discount off the registration fee with the source code: SFAD http://p.sf.net/sfu/XcvMzF8H ___ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user
[Gambas-user] Problem with Byte datatype ?
Hi evererybody, If I code the few lines showed below: DIM X AS Byte DIM Texte AS String[64] X = h2E X += hE0 TextBox1.Text = Hex(X) Texte[X] = Hex(X) I get '10E' displayed. Is this correct for a byte? If you put a breakpoint on the TextBox1 line, the local variables show X value as 14 (h0E) which is correct. and the last line ends wit an 'out of bounds' message. (as a workaround, I actually insert a' X = X MOD 256' instruction just before the last line) If you wonder why the hell I've to use bytes, I'm working on a memory capture of an Amiga program (Captive) running inside the emulator WinUAE. In those old days (twenty years ago), memory was 0.0005 Gb and byte usage was quite common! and more, the memory byte order was not compatible with the actual PC so you have to read memory byte by byte to restore the Amiga organisation regards, Dominique Simonart -- This SF.net email is sponsored by: SourcForge Community SourceForge wants to tell your story. http://p.sf.net/sfu/sf-spreadtheword ___ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user
Re: [Gambas-user] Signal 11 while initializing a property
Jussi (sorry for the preceding Julien) I wonder if our problems are really the same! Here is more details of my situation. As you can see, the READ should know that the datatype of hMyClas[i].X *is* a byte hMyClass.Resize(9) FOR i = 0 TO 8 hMyClass[i] = NEW MyClass ' using these two 2 instructions works fine READ #hFile, N hMyClass[i].X = N ' using this one ends with Signal 11 message 'READ #hFile, hMyClass[i].X NEXT If you want to test, I join the complete source (with the file to read) as it is very small (15.4K) regards Dominique Simonart Simonart Dominique a écrit : Hi Julien, You are right! I read your post and I understand the reason, but you don't speak about Signal 11, so I was thinking for another problem although similar regards, Dominique Simonart Jussi Lahtinen a écrit : Hi! Is hMyClass declared as Object[] ? If so, READ cannot recognise hMyClass[i].X as byte. See my earlier post Minor bug with READ WRITE commands?. I think you have same problem than I did, and in fact it is not bug. Jussi On Thu, Jan 22, 2009 at 1:06 AM, Dominique SIMONART simonart.domini...@wanadoo.fr wrote: Hi everybody, Gambas 2.8, OpenSuse 11.0, Kde 3.5, with Qt If I initialize my property with the next 2 lines, it's OK ( N and the X property are defined as Byte, i is an Integer) READ #hFile, N hMyClass[i].X = N But if I want to write it shorter with the line below, it ends with a signal 11! READ #hFile, hMyClass[i].X Why? Thanks for your help Dominique Simonart -- This SF.net email is sponsored by: SourcForge Community SourceForge wants to tell your story. http://p.sf.net/sfu/sf-spreadtheword ___ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user -- This SF.net email is sponsored by: SourcForge Community SourceForge wants to tell your story. http://p.sf.net/sfu/sf-spreadtheword ___ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user
[Gambas-user] Signal 11 while initializing a property
Hi everybody, Gambas 2.8, OpenSuse 11.0, Kde 3.5, with Qt If I initialize my property with the next 2 lines, it's OK ( N and the X property are defined as Byte, i is an Integer) READ #hFile, N hMyClass[i].X = N But if I want to write it shorter with the line below, it ends with a signal 11! READ #hFile, hMyClass[i].X Why? Thanks for your help Dominique Simonart -- This SF.net email is sponsored by: SourcForge Community SourceForge wants to tell your story. http://p.sf.net/sfu/sf-spreadtheword ___ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user
Re: [Gambas-user] about compilation of Gambas
Thanks Benoit, sorry for my evident ignorance! Benoit Minisini a écrit : On lundi 16 juin 2008, Dominique SIMONART wrote: Hi everybody, I'm not familiar with Linux, know nothing about svn and use OpenSuse 10.3. I actually use Gambas2 V2.0 and want to uptadate to v2.7 from trunk, I followed the guide found in the online documentation (by the way, the name of the repository is not correct in the doc but I managed to retrieve an old message from this list with the right name) The svn path indicated in the download page of web site are the correct one. But for downloading a specific release, you don't have to read the subversion repository. I generate tar.gz archives that you can download from sourceforge. Links are on the download page too. So, in order to install the last version I just have to type $ svn checkout https://gambas.svn.sourceforge.net/svnroot/gambas/gambas/branches/2.0 Right? I think the downloading was correct and I get a folder 'gambas' with 3 sub-folders: 'branches', 'tags' and 'trunk'. Here is my first question : 1) The Gambas folder is quite big : 1.4 Go, 289139 files and 72558 subfolders. Is this a normal situation? LOL: you downloaded EVERYTHING! The current development version (3.x), the stable version (2.x), all releases (2.0, 2.1, 2.2... 2.7), all specific branches (temporary modifications made by specific developers). Thanks to you, I know now how much room it takes. :-) The organization is the following: '/branches/2.0' is the next 2.x version. '/trunk' is the current development tree (next 3.0 version) '/tags' contains each release of Gambas. since I downloaded everything :-) : 1) I started the compilation in the 'trunk' subfolder. Wich version of Gambas could I get at the end? 2) what could be safety deleted? With the dependancies, I did not found : mysql-devel, mysql-shared, firebird. Next, I started ./reconf-all and ./configure -C (some minor options were discarded here, but nothing important for me) finally, I started make and it ended with the following messages (see the joined text file) so I did not start the 'make install' process) 2) What is wrong here? Hmm. Don't know... Which exact versions of qt are installed on your system? v3.3.8-76.2 Thanks for you patience! regards, - Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://sourceforge.net/services/buy/index.php ___ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user