Re: [Gambas-user] How to read mouse wheel string
May be you have to make Clipboard.Copy() before to Paste? hth Simonart Le 13/04/2013 17:32, Fabien Bodard a écrit : I don't know... Le 13 avr. 2013 14:24, Ru Vuott vu...@yahoo.it a écrit : Thank you Fabien, but if I want to use clipboard.Paste() Gambas function, after simply highlighted an external text, it doesn't work. It works, if I highlight the (external) text and I use ctrl+C function or Copy function from right button of mouse. I repeat: if I highlight an external text and after simply I use clipboard.Paste(), my Gambas application doesn't get and doesn't show that text. --- Ven 12/4/13, Fabien Bodard gambas...@gmail.com ha scritto: Da: Fabien Bodard gambas...@gmail.com Oggetto: Re: [Gambas-user] How to read mouse wheel string A: mailing list for gambas users gambas-user@lists.sourceforge.net Data: Venerdì 12 Aprile 2013, 21:28 http://gambasdoc.org/help/comp/gb.qt4/clipboard/paste?v3 Le 12 avr. 2013 19:50, Ru Vuott vu...@yahoo.it a écrit : Hello, how to store the string saved in the mouse from an external text directly to a string variable (I mean the highlighted text by mouse operation and you can see by clicking on mouse wheel). Regards vuott -- Precog is a next-generation analytics platform capable of advanced analytics on semi-structured data. The platform includes APIs for building apps and a phenomenal toolset for data science. Developers can use our toolset for easy data analysis visualization. Get a free account! http://www2.precog.com/precogplatform/slashdotnewsletter ___ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user
Re: [Gambas-user] String and textboxes
Hi, With Gambas2 v2.21 it works exactly as you want! Tested with Label and TextBox regards Le 08/03/2011 20:11, k p a écrit : When doing the following: TextLabel1.Text = i TextBox1.TextiEQU 0 I expect a string in a text box, which I get. However the length of the spacing stays the same no matter how many spaces I put between the What I'm trying to achieve is that the output string follows my coding standard. Ie if I write Callbutton in TextBox1, then the output shows iCallbutton iEQU 0 What am I doing wrong ? Kim I'm not sure what you exactly do here in your program, but your example above consists of string constants. You would have to vary the number of spaces according to the length of the strings in TextBox1.Text, such as space$(20 - string.len(TextBox1.Text)) to give just an example for UTF-8. Or did I get you completely wrong here? Regards Rolf What is happening is that white spaces does NOT change in the output textbox, no matter how many white spaces I put in between the. Ie and produces the same output in the text box. So I get the following iCallbutton iEQU 0 When I would expect this iCallbutton iEQU 0 Hmm Kim -- What You Don't Know About Data Connectivity CAN Hurt You This paper provides an overview of data connectivity, details its effect on application quality, and explores various alternative solutions. http://p.sf.net/sfu/progress-d2d ___ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user -- What You Don't Know About Data Connectivity CAN Hurt You This paper provides an overview of data connectivity, details its effect on application quality, and explores various alternative solutions. http://p.sf.net/sfu/progress-d2d ___ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user
[Gambas-user] feature suggestion
Hi, Often I've to write things like that: With Joueur(0) If Joueur(2).Nombre(Joueur(2).C1) .Nombre(.C1) Then ... ... End With As I already have a With Joueur(0) activated I cannot define another one for Joueur(2). It would be nice to have the possibility to define temporary Alias names inside a Procedure, as for example: ALIAS Joueur(2), J2 With Joueur(0) IF J2.Nombre(J2.C1) .Nombre(.C1) Then ... ... End With regards, Dominique Simonart -- Gaining the trust of online customers is vital for the success of any company that requires sensitive data to be transmitted over the Web. Learn how to best implement a security strategy that keeps consumers' information secure and instills the confidence they need to proceed with transactions. http://p.sf.net/sfu/oracle-sfdevnl ___ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user
Re: [Gambas-user] feature suggestion
Of course you are right! The Joueur() instances of my class are quite big, but nowadays the RAM is gigantic! this is surely a reminiscence of my economy of RAM syndrom coming from the Amiga's days (512KK) so, Forget it! regards Dominique Simonart Le 09/01/2011 23:06, Benoît Minisini a écrit : Hi, Often I've to write things like that: With Joueur(0) If Joueur(2).Nombre(Joueur(2).C1) .Nombre(.C1) Then ... ... End With As I already have a With Joueur(0) activated I cannot define another one for Joueur(2). It would be nice to have the possibility to define temporary Alias names inside a Procedure, as for example: ALIAS Joueur(2), J2 With Joueur(0) IF J2.Nombre(J2.C1) .Nombre(.C1) Then ... ... End With regards, Dominique Simonart Maybe you can use a variable named J2 for that? -- Gaining the trust of online customers is vital for the success of any company that requires sensitive data to be transmitted over the Web. Learn how to best implement a security strategy that keeps consumers' information secure and instills the confidence they need to proceed with transactions. http://p.sf.net/sfu/oracle-sfdevnl ___ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user
Re: [Gambas-user] About help and arrays and variables
Le 19/11/2010 14:58, Fabien Bodard a écrit : 2010/11/19 Demosthenes Koptsisdemosthen...@gmail.com: ok! i was cofused from two things Hi all, I tend to get a little confused too! Are these assumptions correct? If array notation is on Variable name, array is STATIC If array notation is on Data type, array is DYNAMIC 1) in previous message about static arrays Fabien said that: yes a static array is not an object ... that's why it's a little bit deprecated :) anther way : dim htmpArray as integer[]= [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] so a DIM htmpArray as integer[]= [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] i thought was a static. no a dynamic ... look at the bottom and 2) - DIM aInt2 AS Integer[3] aInt2[0] = 1 aInt2[1] = 20 aInt2[2] = 30 aInt2.Add(40) 'here is the resize of the array aInt2.Add(50) aInt2.Add(60) PRINT aInt2[3] PRINT aInt2[4] PRINT aInt2[5] - In my gambas2-2.21 rev3300 there is no error, nor compilation nor execution! Normal it's Dynamic array :) Dynamic : DIM Identifier AS [ NEW ] Native Datatype [ Array dimensions ... ] ex : dim aInt as Integer[10] Static [ STATIC ] { PUBLIC | PRIVATE } Identifier [ Array dimensions ... ] AS Native Datatype ex : Private aInt[10] as integer you can't declare a staic array in a sub -- Beautiful is writing same markup. Internet Explorer 9 supports standards for HTML5, CSS3, SVG 1.1, ECMAScript5, and DOM L2 L3. Spend less time writing and rewriting code and more time creating great experiences on the web. Be a part of the beta today http://p.sf.net/sfu/msIE9-sfdev2dev ___ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user
Re: [Gambas-user] Huge executable.
Le 22/10/2010 16:33, Fabien Bodard a écrit : 2010/10/22 Demosthenes Koptsisdemosthen...@gmail.com: i use Gambas 2.21 on Ubuntu 10.04. i test the project at 32bit and 64 bit Pcs and produce the same behavior (huge executable) this is the project http://www.mediafire.com/file/0lq893dt8yo02l3/Gambas-AVG-GUI-8.tar.gz 2010/10/22 Benoît Minisinigam...@users.sourceforge.net On Mon, 2010-10-04 at 21:46 +0200, Benoît Minisini wrote: I created a project with gb.gui. I changed the components from gb.gui to gb.qt and tried to compile the project. The result was to create a name.gambas file 2 Gb and to crash the IDE. When i tried to reopen the project, in order to change the components i get an error message like the attached image. Can I have your project (without the 2Gb file of course!) ? Hi i have finished my project about a GUI for AVG Antivirus Linux free edition. But i still have problem about creating the executable. When i run compile or compile all, all are perfect. When i run the project with Gambas IDE, all are perfect. But when i run the make executable i get a huge file which increasing in Mb for all the time when IDE run. I must kill the Gambas IDE and then delete the huge executable (over 2Gb). Benoit where can i send my project? It is 1,2 Mb To my private e-mail (don't you see it in your mail client?), or put it on some server and send me a link to it. Regards, -- Benoît Minisini -- Nokia and ATT present the 2010 Calling All Innovators-North America contest Create new apps games for the Nokia N8 for consumers in U.S. and Canada $10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store http://p.sf.net/sfu/nokia-dev2dev ___ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user -- Γεια χαρα σε όλους!!! Regards, Demosthenes Koptsis -- Nokia and ATT present the 2010 Calling All Innovators-North America contest Create new apps games for the Nokia N8 for consumers in U.S. and Canada $10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store http://p.sf.net/sfu/nokia-dev2dev ___ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user where are you saving the executable ? Hi, I remember such a problem long time ago! The destination folder was the same as the source one. Each time you generate the executable, you integrate the preceding executable into the new one hth Dominique Simonart -- Nokia and ATT present the 2010 Calling All Innovators-North America contest Create new apps games for the Nokia N8 for consumers in U.S. and Canada $10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store http://p.sf.net/sfu/nokia-dev2dev ___ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user
Re: [Gambas-user] How to create event to control created at runtime
Hi, Just add As ClickEventName regards Le 12/05/2010 17:18, craf a écrit : Hi. I would like to know how to associate a click event to a button control created at runtime. I know the code to create the button is: Dim myButton as new Button (Fmain) but what I need is to create the click event for this button and the button to call the click event. Regards -- ___ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user -- ___ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user
Re: [Gambas-user] fastest way to zero-out a huge binary file
Hi, May be I've to elaborate a little bit? I see the process like this: 1) you transpose each cell of your initial array to a pixel of a picture where the coordinates of the pixel is equal to the coordinate of the cell and the grey color of the pixel is equal to the elevation in the cell 2) you zoom the picture (200%): basically, each initial pixel become a square of 4 pixels all the same color, but I'm sure there are functions to evaluate three of them in intermediate color according the color of the neighbour pixels (Hope you understand what I mean!) so the final picture is as precise and smooth as the initial picture was, but four times bigger. 3) you repeat 2) a number of times 4) you transpose each pixels from the final picture to the cells of an array where each cells contains the elevation equal to the grey value of the corresponding pixel. My english skill can not permit me to say more. Please, if someone could correct me, thanks in advance to do it! regards, Dominique Simonart Le 25/01/2010 00:17, Simonart Dominique a écrit : Hi, I've just a crude idea and know nothing more on this subject! If you assume that each value in your big array is a color value instead of an integer, may be you can find some graphic effect wich simulate your algorithm. It seems to me that it's like to find an intermediate color between 2 others. Think each cell of your final array as a colored pixel with color equal to the elevation The graphical chips are so sophisticated and powerfull that they could accelerate your process by a one million factor HTH Dominique Simonart -- Throughout its 18-year history, RSA Conference consistently attracts the world's best and brightest in the field, creating opportunities for Conference attendees to learn about information security's most important issues through interactions with peers, luminaries and emerging and established companies. http://p.sf.net/sfu/rsaconf-dev2dev ___ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user
Re: [Gambas-user] fastest way to zero-out a huge binary file
Hi, I've just a crude idea and know nothing more on this subject! If you assume that each value in your big array is a color value instead of an integer, may be you can find some graphic effect wich simulate your algorithm. It seems to me that it's like to find an intermediate color between 2 others. Think each cell of your final array as a colored pixel with color equal to the elevation The graphical chips are so sophisticated and powerfull that they could accelerate your process by a one million factor HTH Dominique Simonart -- Throughout its 18-year history, RSA Conference consistently attracts the world's best and brightest in the field, creating opportunities for Conference attendees to learn about information security's most important issues through interactions with peers, luminaries and emerging and established companies. http://p.sf.net/sfu/rsaconf-dev2dev ___ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user
Re: [Gambas-user] LEN()
Hi, Len() function is based on one-byte character, but some characters need 2 bytes code, like the german's you mentionned. Use the String class methods and all will works as you expected HTH Dominique Simonart Norarg a écrit : hi, I get a bit strange results from the LEN()-function. If there are characters like the German Umlaute in the string (äöüÄÖÜß), the result just does not fit. It seems to me, that LEN(ä) gives back 2 instead of 1, is this possible? I fill up a string with spaces for a more (or less) formatted simple text-file, the columns separated with |. Using Tabs (chr(9)) gives me more work, and it would not solve this problem, because I still would have to ask for the string-lenght. Any ideas? Thanks in advance regards norarg -- Return on Information: Google Enterprise Search pays you back Get the facts. http://p.sf.net/sfu/google-dev2dev ___ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user -- Return on Information: Google Enterprise Search pays you back Get the facts. http://p.sf.net/sfu/google-dev2dev ___ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user
Re: [Gambas-user] The define style of many element string array
Steven James Drinnan a écrit : As far as I know just one by one. Write one line by one line. ss[0] = jkl ss[1] = 9080| ss[2] = jim ss[3] = ren ss[4] = mu8 I may be wrong and others can give there 2 cents worth. Steven On Thu, 2009-06-25 at 15:40 -0700, Swee Kwang Tan wrote: Dear Sir, Thank you for your reading. I have a string array, there is many element string. like this dim ss as string[] = [jkl, 9080|, jim, ren, mu8, vcnm, m83d, m09nc, n83f, iiop', qiop..] a longl long line, it have 65 sub-string. How do I write it smart ? If someone type error or change someone, editor hard to edit ? Thank you may be like this Dim sChain AS String Dim ss AS String[] sChain = jkl,9080,jim,ren,mu8,vcnm,m83d,m09nc, sChain = n83f,iiop,qiop,aaa1,bbb1,ccc1,ddd1,eee1, sChain = fff1,ggg1,hhh1,iii1,j1j1,k1k2,l1a2 ' etc ss = SPLIT(sChain,,) hope this help Dominique -- ___ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user
Re: [Gambas-user] Pb with transparency?
Benoît Minisini a écrit : Hi, Gambas 2.12 with QT I had a prog that worked well in Gambas 2.11 but now it doesn't work correctly for all the images with transparent areas. Here is a very short illustration of the problem DIM PicSac AS Picture DIM PicCase AS Object[] Dim i AS Integer PicCase.Resize(2) FOR i = 0 TO 1 PicCase[i] = NEW Picture(14, 14, TRUE) NEXT PicCase[0] = Picture.Load(image with some transparent part) PicCase[1] = Picture.Load(image without transparent area) PicSac = NEW Picture(14, 14, TRUE) i = 0 Draw.Begin(PicSac) Draw.Picture(PicCase[i], 0, 0, 14, 14, 0, 0, 14, 14) Draw.End PictureBox1.Picture = PicSac i = 0 = nothing displayed i = 1 = correct display (I know that Gambas 2.12 changed the Draw routine) Is it a bug? regards, Dominique Simonart I will look at that. Beware that the Picture class is not really transparent. It has no alpha channel but a bitmap mask. Creating a transparent Picture internally creates an X11 pixmap and a X11 bitmap mask. Drawing on it the must update both the pixmap and the mask. I think that the mask update is buggy for the Draw.Picture() method. Anyway, you should use the Image class and its Draw method to draw an image on top another one with real alpha transparency. To add to the complexity, converting an Image to a Picture keeps the alpha information with gb.qt, but not with gb.gtk. This is a Qt feature, that uses the XRender extension for that. But GTK+ don't, and just removes all pixels whose alpha component is lower than 128. But you should not take that into account as it is really toolkit specific. Regards, Thanks Benoit, I replaced PicCase[] and PicSac by Image and used Draw method instead of Draw.Begin(...). The last instruction is now: PictureBox1.Picture = PicSac.Picture Here are the results: 1) i=0 now display correctly the image with transparent part 2) If I use 2 buttons to draw with i=0 (button1) and i=1 (button2) * button1 then button2 display correctly the two images successively * button2 then button1 display only the image without transparent part (button1 didn't change the display) * if I replace Image1 with another image without transparent part I could see the images associated with their buttons In conclusion, as soon as there is a transparent part in my image, it could never override another image Hope this helps Dominique Simonart -- Crystal Reports #45; New Free Runtime and 30 Day Trial Check out the new simplified licensign option that enables unlimited royalty#45;free distribution of the report engine for externally facing server and web deployment. http://p.sf.net/sfu/businessobjects ___ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user
Re: [Gambas-user] Pb with transparency?
Benoît Minisini a écrit : Benoît Minisini a écrit : Hi, Gambas 2.12 with QT I had a prog that worked well in Gambas 2.11 but now it doesn't work correctly for all the images with transparent areas. Here is a very short illustration of the problem DIM PicSac AS Picture DIM PicCase AS Object[] Dim i AS Integer PicCase.Resize(2) FOR i = 0 TO 1 PicCase[i] = NEW Picture(14, 14, TRUE) NEXT PicCase[0] = Picture.Load(image with some transparent part) PicCase[1] = Picture.Load(image without transparent area) PicSac = NEW Picture(14, 14, TRUE) i = 0 Draw.Begin(PicSac) Draw.Picture(PicCase[i], 0, 0, 14, 14, 0, 0, 14, 14) Draw.End PictureBox1.Picture = PicSac i = 0 = nothing displayed i = 1 = correct display (I know that Gambas 2.12 changed the Draw routine) Is it a bug? regards, Dominique Simonart I will look at that. Beware that the Picture class is not really transparent. It has no alpha channel but a bitmap mask. Creating a transparent Picture internally creates an X11 pixmap and a X11 bitmap mask. Drawing on it the must update both the pixmap and the mask. I think that the mask update is buggy for the Draw.Picture() method. Anyway, you should use the Image class and its Draw method to draw an image on top another one with real alpha transparency. To add to the complexity, converting an Image to a Picture keeps the alpha information with gb.qt, but not with gb.gtk. This is a Qt feature, that uses the XRender extension for that. But GTK+ don't, and just removes all pixels whose alpha component is lower than 128. But you should not take that into account as it is really toolkit specific. Regards, Thanks Benoit, I replaced PicCase[] and PicSac by Image and used Draw method instead of Draw.Begin(...). The last instruction is now: PictureBox1.Picture = PicSac.Picture Here are the results: 1) i=0 now display correctly the image with transparent part 2) If I use 2 buttons to draw with i=0 (button1) and i=1 (button2) * button1 then button2 display correctly the two images successively * button2 then button1 display only the image without transparent part (button1 didn't change the display) * if I replace Image1 with another image without transparent part I could see the images associated with their buttons In conclusion, as soon as there is a transparent part in my image, it could never override another image Hope this helps Dominique Simonart I fixed many bugs in Draw.Picture() and Draw.Image() in revision #1938, both for gb.qt and gb.gtk. Can you try it to check if you have the same problems? Regards, Hi Benoit, I'm sorry Benoit, but I don't install Gambas from svn, I use the rpms built by Guillermo Ballester Valor for OpenSuse (gambas 2.12-3.7). I don't know the revision level I'm using. regards, Dominique Simonart -- Crystal Reports #45; New Free Runtime and 30 Day Trial Check out the new simplified licensign option that enables unlimited royalty#45;free distribution of the report engine for externally facing server and web deployment. http://p.sf.net/sfu/businessobjects ___ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user
[Gambas-user] Pb with transparency?
Hi, Gambas 2.12 with QT I had a prog that worked well in Gambas 2.11 but now it doesn't work correctly for all the images with transparent areas. Here is a very short illustration of the problem DIM PicSac AS Picture DIM PicCase AS Object[] Dim i AS Integer PicCase.Resize(2) FOR i = 0 TO 1 PicCase[i] = NEW Picture(14, 14, TRUE) NEXT PicCase[0] = Picture.Load(image with some transparent part) PicCase[1] = Picture.Load(image without transparent area) PicSac = NEW Picture(14, 14, TRUE) i = 0 Draw.Begin(PicSac) Draw.Picture(PicCase[i], 0, 0, 14, 14, 0, 0, 14, 14) Draw.End PictureBox1.Picture = PicSac i = 0 = nothing displayed i = 1 = correct display (I know that Gambas 2.12 changed the Draw routine) Is it a bug? regards, Dominique Simonart -- Crystal Reports #45; New Free Runtime and 30 Day Trial Check out the new simplified licensign option that enables unlimited royalty#45;free distribution of the report engine for externally facing server and web deployment. http://p.sf.net/sfu/businessobjects ___ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user
Re: [Gambas-user] Object creating properties? ball.speed, ball.solid, etc
jbskaggs a écrit : I need to know how to either create an object to where I can attach a list of variables or how to give myself the ability to do the following: lets say I want to name my special object: ball. I want to be able to create special properties for that ball I can access with .property (or variable) for example: ball.speed ball.solid ball.item ball.gravity ball.life etc... I don't mean Gambas, I mean just being able to attach variables to an object like I mentioned. I write a lot of games and this is something I need to know how to do or at least get close to it. I have read all the docs I can find and I am probably overlooking it. JB Skaggs Hi JB, May be I don't understand the real question? You just have to create a class, let say BallModel, add properties to it, like speed, solid, etc.. Then you have to create an instance of that class , let say Ball and initialize its properties. :) Hope this is what you ask for Dominique Simonart -- Stay on top of everything new and different, both inside and around Java (TM) technology - register by April 22, and save $200 on the JavaOne (SM) conference, June 2-5, 2009, San Francisco. 300 plus technical and hands-on sessions. Register today. Use priority code J9JMT32. http://p.sf.net/sfu/p ___ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user
Re: [Gambas-user] binary numeral system
vlahonick vlahonick a écrit : hello all :D i am trying to create a program that calculates a number from the binary numeral system and gives a result example of what the program will do : we have the number (at binary numeral system) 10011 so to have result we have to do (1*2^4)+(0*2^3)+(0*2^2)+(1*2^1)+(1*2^0)= 16+0+0+2+1=19 to do that in a program first i have to calculate the powers so i have to write (y=number of digits) for the first of the digits y-1,second y-2etc so if i have 5 digits then the power for the first one will be y-1=5-1=4 this is done by the Len(textbox1.text) but HOW i will write Len(textbox1.text)=y ? then how i can make the program to recognize that for the 1st digit entered in the Textbox1.text have to give (d*2^y-1) (d=the digit that can be 0 or 1 and y the number of the digits) for the second (d*2^y-2)etc... so the main question is how i can make JUST ONE TEXTBOX to understand that for every digits enter it will give something else for a result As an exercise for myself, I modify the program so the decimal value is displayed for each binary digit you typed. Now, you don't need to click a button to know the value. I could say it was not simple to understand how works this TextArea update with the cursor position STATIC PUBLIC DecVal AS Integer STATIC PUBLIC InputChain AS String PUBLIC SUB Form_Open() Button1_Click() END PUBLIC SUB Button1_Click() ' CLEAR button DecVal = 0 InputChain = TextArea1.Clear END PUBLIC SUB TextArea1_KeyPress() DIM K as String K = Key.Text IF K 0 AND K 1 THEN RETURN DecVal *= 2 DecVal += Val(K) TextArea1.Text = InputChain \nBinary InputChain K = decimal Str(DecVal) TextArea1.Pos = Len(InputChain) InputChain = K END Look how I have to separate InputChain and K to initialize the Text property. You must add the K character to the InputChain *after* the modification of the TextArea. Hope this help Dominique Simonart -- Stay on top of everything new and different, both inside and around Java (TM) technology - register by April 22, and save $200 on the JavaOne (SM) conference, June 2-5, 2009, San Francisco. 300 plus technical and hands-on sessions. Register today. Use priority code J9JMT32. http://p.sf.net/sfu/p ___ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user
Re: [Gambas-user] binary numeral system
vlahonick vlahonick a écrit : hello all :D i am trying to create a program that calculates a number from the binary numeral system and gives a result example of what the program will do : we have the number (at binary numeral system) 10011 so to have result we have to do (1*2^4)+(0*2^3)+(0*2^2)+(1*2^1)+(1*2^0)= 16+0+0+2+1=19 to do that in a program first i have to calculate the powers so i have to write (y=number of digits) for the first of the digits y-1,second y-2etc so if i have 5 digits then the power for the first one will be y-1=5-1=4 this is done by the Len(textbox1.text) but HOW i will write Len(textbox1.text)=y ? then how i can make the program to recognize that for the 1st digit entered in the Textbox1.text have to give (d*2^y-1) (d=the digit that can be 0 or 1 and y the number of the digits) for the second (d*2^y-2)etc... so the main question is how i can make JUST ONE TEXTBOX to understand that for every digits enter it will give something else for a result sorry about my english but it has been long time since i had english lessons... plz if u dont understand something let me know and i will try to explain better... if you want to contact me directly :tsopanotr...@hotmail.com | vlahon...@gmail.com | ch...@vlahonick.freehost.gr thanks in advance Vlahonick (all the truth is always in www.vlahonick.freehost.gr) _ News, entertainment and everything you care about at Live.com. Get it now! http://www.live.com/getstarted.aspx -- 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 Hi Vlahonick, I'm not sure to understand exactly what you want to do! 1) If you want to convert a bynary number to decimal value, you just have to write in Gambas exactly what you sayd in your message! :) 2) If you want to display the changing decimal value as soon as you enter a binary digit, this is not possible because you don't know what WILL be the final length of the binary number! For the 1) comprehension, here is an exemple (I took a TextArea because I want to start a new line in the text) PUBLIC SUB Button1_Click() DIM S AS String DIM i, y, N AS Integer S = TextArea1.Text y = Len(S) if y = 0 THEN RETURN N = 0 FOR i = 1 to y d = Val(Mid(S, i, 1)) ' I assume that d is 0 or 1 N += d * (2 ^ (y-i)) NEXT TextArea1.Text = \nBinary S = decimal Str(N) END Hope I understand you! 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] binary numeral system
Ron_1st a écrit : On Tuesday 14 April 2009, Simonart Dominique wrote: PUBLIC SUB Button1_Click() DIM S AS String DIM i, y, N AS Integer S = TextArea1.Text y = Len(S) if y = 0 THEN RETURN N = 0 FOR i = 1 to y d = Val(Mid(S, i, 1)) ' I assume that d is 0 or 1 N += d * (2 ^ (y-i)) NEXT TextArea1.Text = \nBinary S = decimal Str(N) END function bin2dec(sBin) as long dim r as long r=0 for i= 1 to len(sBin) r = r*2 + Val(Mid(sBin, i, 1)) next return r end PUBLIC SUB Button1_Click() TextArea1.Text = \nBinary TextArea1.Text = decimal bin2dec(TextArea1.Text) END for 10011 as sBin the sequence is as follows: r*2=0 +1 = 1 r*2=2 +0 = 2 r*2=4 +0 = 4 r*2=8 +1 = 9 r*2=18 +1 =19 I does not matter the size of input string. The only limit is r should of apropiate type to hold the result. Multiply is faster as Power Best regards, Ron_1st Thanks Ron! You're right, there is no need to use the power factor at all! My mind was not opened enough to see that! -- 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] A random sort of listview
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 13 19 0 18 13 17 11 16 4 15 9 14 12 13 4 12 2 11 6 10 2 9 4 8 0 7 5 6 1 5 3 4 3 3 0 2 0 1 0 0 0 Here, you listed i and a but the interesting values are i and myArray[i] instead This list shows where listview1 is being copied into listview2: listview1.item.key 21 counter i: 21 total count: 22 listview1.item.key 13 counter i: 20 total count: 22 listview1.item.key 13 counter i: 19 total count: 22 listview1.item.key 20 counter i: 18 total count: 22 listview1.item.key 11 counter i: 17 total count: 22 listview1.item.key 4counter i: 16 total count: 22 listview1.item.key 9counter i: 15 total count: 22 listview1.item.key 12 counter i: 14 total count: 22 listview1.item.key 16 counter i: 13 total count: 22 listview1.item.key 2counter i: 12 total count: 22 listview1.item.key 6counter i: 11 total count: 22 listview1.item.key 14 counter i: 10 total count: 22 listview1.item.key 18 counter i: 9total count: 22 listview1.item.key 19 counter i: 8total count: 22 listview1.item.key 5counter i: 7total count: 22 listview1.item.key 5counter i: 6total count: 22 listview1.item.key 3counter i: 5total count: 22 listview1.item.key 7counter i: 4total count: 22 listview1.item.key 8counter i: 3total count: 22 listview1.item.key 15 counter i: 2total count: 22 listview1.item.key 10 counter i: 1total count: 22 listview1.item.key 17 counter i: 0total count: 22 here is a screen shot of the two lists: listview1 is on the left, you will notice that the last two items are not on the random sorted list on the right. First, is it correct that you have twice the keys 13 and 5 in ListView1 and that keys 0 and 1 are missing? I tried to reproduce exactly your keys sequence but as soon as I want to add an identical key, I get a message and the programme stop immediatly. http://www.nabble.com/file/p23005690/ScreenshotBug.png Here is my code: PUBLIC SUB button4_click() DIM myArray AS Integer[ListView1.count] DIM a AS Integer DIM i AS Integer DIM c AS String 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 FOR i = ListView1.count - 1 TO 0 STEP -1 ' write items in listview2 - I have also tried running this counting up as well but it changed nothing. listview1.MoveTo(myArray[i]) TRY c = listview1.Item.Key TRY PRINT listview1.item.key , c, counter i: , i, total count: , listview1.Count TRY listview2.add(c, listview1.item.text) NEXT 'fGlobal.show 'FRolldice.Show 'ME.Hide END Sincerly JB SKaggs I run your code and it works quite fine! I think your missing items come from the duplicated keys 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] A random sort of listview
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 :) so you got the good result! Since these values cannot change after they were selected in the Backward FOR NEXT loop case, my mistake had no consequence. We could consider this as a more efficient method since the correct result is available sooner! Dominique Simonart Jussi Lahtinen a écrit : 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 test: DIM ii AS Integer DIM jj AS Integer DIM a AS Integer DIM myArray AS Integer[200] DIM checkArray AS NEW Integer[] RANDOMIZE 12345 FOR ii = 0 TO 9 '199 myArray[ii] = ii NEXT FOR ii = 0 TO 9 '199 ' random swap array items a = Int(Rnd(ii + 1)) SWAP myArray[ii], myArray[a] NEXT FOR ii = 0 TO 9 '199 ' Check against duplicates. PRINT myArray[ii] FOR jj = 0 TO 9 '199 IF myArray[ii] = jj THEN IF checkArray.Exist(jj) = FALSE THEN checkArray.Add(jj) ELSE Message.Error(Error!) RETURN ENDIF ENDIF NEXT NEXT PRINT checkArray.Count On Wed, Apr 8, 2009 at 00:12, Simonart Dominique simonart.domini...@wanadoo.fr wrote: 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 myArray values inside the SAME for next loop that the swap! But of course, the values could change at each next step However, there is differences. Let see a step by step sample CASE 1: Forward FOR NEXT loop * i=0 - Int(Rnd(i+1)) = 0! you could affect only myArray[0] to myArray[0] * i=1 - Int(Rnd(i+1)) = 0-1 you could affect myArray[0] once more * i=2 - Inn(Rnd(i+1)) = 0-2 idem * i=3 ... at each step, ALWAYS you could affect an already selected value CASE 2: Backward FOR NEXT loop * i=199 - Int(Rnd(i+1)) = 0-199 myArray[199] could be any value * i=198 - Int(Rnd(i+1)) = 0-198 myArray[198] could be any of the non selected values myArray[199] will never be affected anymore * i=197 ... at each step, NEVER you could affect an already selected value I found the second case more satisfying for my mind! :) Hope this send your headache away! :) Dominique Simonart Simonart Dominique wrote: 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 with RANDOMIZE 12345 If you run the forward FOR NEXT you will get: 0 0 2 3 1 1 2 6 3 8 which is wrong! but if you run the backward FOR NEXT you will get: 5 1 9 6 0 3 8 7 2 4 which is right! May be you did not notice it because 200 is long enough before you get the same number twice, and before you remark that some are missing? Dominique Simonart Simonart Dominique wrote: 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 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 STEP 1 'add array items myArray[i] = i NEXT FOR i = 0 TO 199 STEP 1 ' random swap array items a = Int(Rnd(i + 1)) SWAP myArray[i], myArray[a] NEXT the right code is: FOR i = 199 TO 0 STEP -1 ... NEXT FOR i = 0 TO 199 STEP 1 ' write items in listview2 listview1.MoveTo(myArray[i]) c = listview1.Item.Key listview2.add(c, listview1.item.text) NEXT FOR i = 0 TO 199 STEP 1 'optional step to write array as a string for file or whatever use b = slot myArray[i] , NEXT PRINT b END PUBLIC SUB Button1_Click() 'an optional way to load the array values from the variable b and / or a file if b was file loaded DIM egg AS String[] DIM c AS String listview1.Clear egg = Split(b, ,) FOR EACH c IN egg TRY listview1.Add(c, c) IF ERROR THEN RETURN NEXT IF listview1.Count = 200 THEN RETURN END JB Skaggs Dominique Simonart Dominique Simonart -- This SF.net email is sponsored by: High Quality Requirements in a Collaborative Environment. Download a free
Re: [Gambas-user] A random sort of listview
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 myArray values inside the SAME for next loop that the swap! But of course, the values could change at each next step However, there is differences. Let see a step by step sample CASE 1: Forward FOR NEXT loop * i=0 - Int(Rnd(i+1)) = 0! you could affect only myArray[0] to myArray[0] * i=1 - Int(Rnd(i+1)) = 0-1 you could affect myArray[0] once more * i=2 - Inn(Rnd(i+1)) = 0-2 idem * i=3 ... at each step, ALWAYS you could affect an already selected value CASE 2: Backward FOR NEXT loop * i=199 - Int(Rnd(i+1)) = 0-199 myArray[199] could be any value * i=198 - Int(Rnd(i+1)) = 0-198 myArray[198] could be any of the non selected values myArray[199] will never be affected anymore * i=197 ... at each step, NEVER you could affect an already selected value I found the second case more satisfying for my mind! :) Hope this send your headache away! :) Dominique Simonart Simonart Dominique wrote: 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 with RANDOMIZE 12345 If you run the forward FOR NEXT you will get: 0 0 2 3 1 1 2 6 3 8 which is wrong! but if you run the backward FOR NEXT you will get: 5 1 9 6 0 3 8 7 2 4 which is right! May be you did not notice it because 200 is long enough before you get the same number twice, and before you remark that some are missing? Dominique Simonart Simonart Dominique wrote: 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 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 STEP 1 'add array items myArray[i] = i NEXT FOR i = 0 TO 199 STEP 1 ' random swap array items a = Int(Rnd(i + 1)) SWAP myArray[i], myArray[a] NEXT the right code is: FOR i = 199 TO 0 STEP -1 ... NEXT FOR i = 0 TO 199 STEP 1 ' write items in listview2 listview1.MoveTo(myArray[i]) c = listview1.Item.Key listview2.add(c, listview1.item.text) NEXT FOR i = 0 TO 199 STEP 1 'optional step to write array as a string for file or whatever use b = slot myArray[i] , NEXT PRINT b END PUBLIC SUB Button1_Click() 'an optional way to load the array values from the variable b and / or a file if b was file loaded DIM egg AS String[] DIM c AS String listview1.Clear egg = Split(b, ,) FOR EACH c IN egg TRY listview1.Add(c, c) IF ERROR THEN RETURN NEXT IF listview1.Count = 200 THEN RETURN END JB Skaggs Dominique Simonart 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 -- 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
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 2 EXCEPT the key for listview2 items = the integer from my for next loop eg for i = 0 to listview1.count -1 step 1 listview2.add(i, listview1.item.text) next then with a for next loop based on the length of list1 I copy the listview.item key to a string A and listview.item.text to second string B Then I calculate a random number the count of listview2 and add that to a integer C thenadd it to listview2 listview2.add(nA, B,,C) nA creates a key of n1, n2, etc ... AFter the loop ends I run a second loop and run for i = 0 to listview1.count -1 step 1 listview.moveto(i) listview2.item.delete next This gives me a random sorted list in viewlist2 of viewlist1 with no duplicates etc- But is there a more efficient way of doing this? here is total code: PUBLIC SUB button3_click() DIM a AS String DIM d AS Integer DIM e AS Integer DIM i AS Integer DIM c AS Integer listview1.Clear 'clears the list FOR i = 0 TO 199 STEP 1 'number of items to add listview2.Add(i, Slot i) 'adds items to sort to list NEXT 'next item i = 0 FOR i = 0 TO 199 STEP 1 'number of items e = 0 listview1.MoveTo(i) 'goto item a = listview1.Item.Text 'get text PRINT a d = listview1.Key 'get key PRINT old key, d listview1.Item.Delete 'delete item (the cut part of cut and paste) e = Round(Rnd(200)) ' make sure old key doesNOT equal NEW Key PRINT e, the randomimzed number IF e = 200 THEN e = 199 listview2.Add(n d, n a,, e) 'adds cut items after randomly chosen item listview3.Add(n d, n a) PRINT new key, e NEXT 'next item down FOR i = 0 TO 199 STEP 1 'number of items listview2.MoveTo(i) listview2.Item.Delete NEXT ValueBox1.value = listview1.Count END JB SKaggs Hi, Let say you want to populate an array with 0-199 randomly (please note that I write this directly, so check carefully the syntax) dim myArray as integer[200] dim A as integer dim i as integer FOR i=0 to 199 A=int(Rnd(200-i)) ' I think we could use a Swap instruction ' instead of the 2 instructions below myArray[i]=A myArray[A]=i NEXT That's all If these numbers was the keys of the initial Listview you just have to populate the second Listview in the new order Hope this help 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] A random sort of listview
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 the listitems from list 1 to list 2 EXCEPT the key for listview2 items = the integer from my for next loop eg for i = 0 to listview1.count -1 step 1 listview2.add(i, listview1.item.text) next then with a for next loop based on the length of list1 I copy the listview.item key to a string A and listview.item.text to second string B Then I calculate a random number the count of listview2 and add that to a integer C thenadd it to listview2 listview2.add(nA, B,,C) nA creates a key of n1, n2, etc ... AFter the loop ends I run a second loop and run for i = 0 to listview1.count -1 step 1 listview.moveto(i) listview2.item.delete next This gives me a random sorted list in viewlist2 of viewlist1 with no duplicates etc- But is there a more efficient way of doing this? here is total code: PUBLIC SUB button3_click() DIM a AS String DIM d AS Integer DIM e AS Integer DIM i AS Integer DIM c AS Integer listview1.Clear 'clears the list FOR i = 0 TO 199 STEP 1 'number of items to add listview2.Add(i, Slot i) 'adds items to sort to list NEXT 'next item i = 0 FOR i = 0 TO 199 STEP 1 'number of items e = 0 listview1.MoveTo(i) 'goto item a = listview1.Item.Text 'get text PRINT a d = listview1.Key 'get key PRINT old key, d listview1.Item.Delete 'delete item (the cut part of cut and paste) e = Round(Rnd(200)) ' make sure old key doesNOT equal NEW Key PRINT e, the randomimzed number IF e = 200 THEN e = 199 listview2.Add(n d, n a,, e) 'adds cut items after randomly chosen item listview3.Add(n d, n a) PRINT new key, e NEXT 'next item down FOR i = 0 TO 199 STEP 1 'number of items listview2.MoveTo(i) listview2.Item.Delete NEXT ValueBox1.value = listview1.Count END JB SKaggs Hi, Let say you want to populate an array with 0-199 randomly (please note that I write this directly, so check carefully the syntax) dim myArray as integer[200] dim A as integer dim i as integer FOR i=0 to 199 A=int(Rnd(200-i)) ' I think we could use a Swap instruction ' instead of the 2 instructions below myArray[i]=A myArray[A]=i NEXT That's all If these numbers was the keys of the initial Listview you just have to populate the second Listview in the new order Hope this help Dominique Simonart Well, never write directly like that!! I make some mistake in my sample, here is a new one: DIM myArray AS Integer[200] DIM A AS Integer DIM i AS Integer 'initialize the array FOR i=0 TO 199 myArray[i]=i NEXT 'Randomize the order of the array FOR i = 199 TO 0 STEP -1 A = Int(Rnd(i + 1)) SWAP myArray[i], myArray[A] NEXT -- 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] Function Len in gambas2
vlahonick vlahonick a écrit : hi again...sorry about the delay in my reply :D but i really didnt understand ur example here of course now i realise that even the textbox2.text had the reasult i wanted the problem will be in the letters appering because of their bytes... but the main problem is not solved yet still in the textbox2.text appears what i am writing in the textbox1.text and not what i want... and abou the example u gave me with if then else end if is a bad idea because if for example we want to converter a word i have to put many boxes and the user to write a letter in every box to have in that many other boxes a result (anyway i tried this but just didnt work...) so plz if u can tell me how i can make with two boxes every character i wrote in the first box to appear what i want in the second box what i wrote wrong???why at the 2nd box appears what i am writing in the 1st box??? plz solve this and then if this problem is solved but in the second or first textbox the charactes doesnt appears in the way the should i will try to set somehow that they are UTF-8 characters so they have more bytes... ty again for ur replies :D:D:D vlahonick...LOVE AND GREETINGS FROM GREECE :D also u can see some of my work in the www.vlahonick.freehost.gr (of course u dont gonna understand many because site is in greek but u can try download my games-www.vlahonick.freehost.gr/downloads.html and press Παιχνίδια=games) here my code for one more time : ' Gambas class file PUBLIC SUB _new() END PUBLIC SUB Form_Open() END PUBLIC SUB Button1_Click() DIM nI AS Integer DIM sAnyChar AS String TextBox2.text = FOR nI = 1 TO Len(TextBox1.Text) sAnyChar = Mid(TextBox1.Text, nI, 1) TextBox2.Text = TextBox2.Text Gronverter(sAnyChar) NEXT END FUNCTION Gronverter(sInChar AS String) AS String DIM sRetChar AS String = sInChar IF sInChar = α THEN sRetChar = a IF sInChar = β THEN sRetChar = v IF sInChar = γ THEN sRetChar = g IF sInChar = δ THEN sRetChar = d IF sInChar = ε THEN sRetChar = e IF sInChar = ζ THEN sRetChar = z IF sInChar = η THEN sRetChar = ι IF sInChar = θ THEN sRetChar = th IF sInChar = ι THEN sRetChar = i IF sInChar = κ THEN sRetChar = k IF sInChar = λ THEN sRetChar = l IF sInChar = μ THEN sRetChar = m IF sInChar = ν THEN sRetChar = n IF sInChar = ξ THEN sRetChar = x IF sInChar = ο THEN sRetChar = o IF sInChar = π THEN sRetChar = p IF sInChar = ρ THEN sRetChar = r IF sInChar = σ THEN sRetChar = s IF sInChar = τ THEN sRetChar = t IF sInChar = υ THEN sRetChar = i IF sInChar = φ THEN sRetChar = f IF sInChar = χ THEN sRetChar = h IF sInChar = ψ THEN sRetChar = ps IF sInChar = ω THEN sRetChar = o RETURN sRetChar END PUBLIC SUB Button2_Click() TextBox1.text = TextBox2.text = END Hi, You have to use the String class because each greek character is 2 bytes long. Change the SUB Button1_Click() as below and all will be fine! (I've tested it) PUBLIC SUB Button1_Click() DIM nI AS Integer DIM sAnyChar AS String TextBox2.text = FOR nI = 1 TO String.Len(TextBox1.Text) sAnyChar = String.Mid(TextBox1.Text, nI, 1) TextBox2.Text = TextBox2.Text Gronverter(sAnyChar) NEXT END -- ___ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user
Re: [Gambas-user] How to compile Gambas in Fedora 10
Marc Miralles a écrit : Hi all: Some idea or link about how to compile Gambas 2.12 or Gambas 3 in Fedora 10 In gambas website don't have information about what packages are necessaries for compile Gambas in Fedora 10 and some components are disabled when compile in Fedora 10. Please, I'm seek for this information in Internet and don't have exit. Some people have this information? thanks Marc -- ___ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user Hi, I don't know about Fedora, but did you read this ? http://gambasdoc.org/help/readme hope this help Dominique Simonart -- ___ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user
Re: [Gambas-user] How to know permanently the cursor coordinates in a gridview?
Benoît Minisini a écrit : 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, Yep. The problem is that mouse move are not always generated. It depends on the internal implementation of the widget in the toolkit. What you can do is enabling a timer at Enter event, and disabling it at Leave event. Ecah timer the timer is triggered, just use the Mouse.ScreenX and Mouse.ScreenY properties to calculate where the cursor is on the GridView. The right solution would be implementing a Tracking property in the Control class to tell Gambas that you want MouseMove events even if no mouse button is pressed. Regards, Thanks Benoit, I've now the thing working! I couldn't think about Mouse.ScreenX/Y because I work with 2.8 version and the Help menu show only Mouse.X/Y and nothing else. In a first try, I used the Enter event to post a flag and start a loop like this WHILE myFlag WAIT 0.2 ...whatever wend and used the Leave event to annulate the flag, but it didn't work (recursivity problem I think) so I changed the loop to break as soon as the cursor get out the Grid limits (this is exactly what the Leave event did I think :) ) and all is runing fine! I had another idea in mind, by using a DrawingArea with transparency and nothing in it and place it over the grid, so I could use the tracking caracteristic, but I would have to manage the grid process myself, so I did not try it yet. 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
Re: [Gambas-user] Problem with Byte datatype ?
Dominique SIMONART a écrit : 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 Sorry for missing needed information: Gambas 2.8 OpenSuse 11.0 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
Thanks Jussi, Now I think I really understand :) Dominique Simonart Jussi Lahtinen a écrit : No, I think it is exactly same problem. Here is the reason (just like in my code): PUBLIC hMyClass AS NEW Object[] Only difference is how we populate that array. I use fResult.Add(aa) and you use hMyClass[i] = NEW MyClass (and hMyClass.Resize(9)). Result is very same. Read my post and followups (see what Benoit has answered) more carefully! hMyClass is object array. And command READ see hMyClass[n] as object, but it could be any kind of object, not always MyClass. In this case, when you have some object with somekind of variable in it, then it is Variant. Basically you are trying to read more memory than you are allowed to, that's why signal 11. Jussi On Fri, Jan 23, 2009 at 1:08 PM, Dominique SIMONART simonart.domini...@wanadoo.fr wrote: Oups, forget to join the source! Dominique SIMONART a écrit : 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
Re: [Gambas-user] Emulating wizard Back/Next navigation
M0E Lnx a écrit : Exactly. The forward navigation depends on the user input, so it could jump from Form1 to Form3 and then to Form2 ans do on... So if we leave a footprint in the array, I think it *should* be easy to reverse the process indeed sort of like an undo process. But I'm not sure exactly what the best way to do the reverse is... should I index the array? or try to find the current form in the array and then just use the current forms.index in the array - 1 ? I've been fidling with this for a while... and it works perfecly in my mind... but can't really make it work on the IDE :( On Thu, Dec 11, 2008 at 2:23 PM, Simonart Dominique simonart.domini...@wanadoo.fr wrote: M0E Lnx a écrit : I have to say, the array idea makes more sense to me, simply because otherwise, it'll be hard to tell the next and back buttons which sub to run. I have tried an array, but object array rather than string array. The idea is that every form that gets opened leaves a footprint in this object array for instance, the form's open() event would have something like this IF ArrNav.find(me) = -1 THEN ArrNav.Add(me) this makes reverse navigation possible by indexing the array or a similar method. However, I am not able to work out all the bugs resulting from this because it gets crazy when you try to move back, then forward... then back... ends up in a crash almost every time Can someone work out a sample I can use? On Thu, Dec 11, 2008 at 6:20 PM, nando nand...@nothingsimple.com wrote: Perhaps the following ideas... Every step in the wizard has an associated form for whatever it does for that step. Every form has a SUB for 'backwards' and 'forwards so that when NEXT is clicked, the forwards code runs, which is whatever is required for moving to the next form (ie: perform work, verify info, hide form, the activate 'next' form) when BACK is clicked, the backwards code runs, which is whatever to undo this step (if needed), hide form, activate 'back' form. Each form knows how to go back one step, and go forward one step. You would have to tell the Next and BAck buttons which forwards and backwards sub to run...you could place in NEXT.tag and BACK.tag the form or info required to properly run the correct code. This would be modular so each form takes care of things. Or, the list of wizard steps could be in a global string array with the name of the form and simply step through the index. -Fernando -- Original Message --- From: M0E Lnx m0e@gmail.com To: mailing list for gambas users gambas-user@lists.sourceforge.net Sent: Wed, 10 Dec 2008 20:39:45 + Subject: [Gambas-user] Emulating wizard Back/Next navigation So I set myself to create a program that acts like a wizard, but chose not to use the wizard object because well, there is just too many variables here, and there is more than one way to get to the end, Depending on user input. So what I did was create a navigation tool bar at the bottom of FMain this toolbar has a BACK, EXIT, and a NEXT button. I have a workspace object above it which will host other forms via each forms .Reparent method. Can anyone suggest a way to make reverse and forward navigation on such a setup? I have created a small project what I'm trying to do... See attachment Any help is appreciated Thanks --- End of Original Message --- -- SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, Nevada. The future of the web can't happen without you. Join us at MIX09 to help pave the way to the Next Web now. Learn more and register at http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.com/ ___ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user -- SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, Nevada. The future of the web can't happen without you. Join us at MIX09 to help pave the way to the Next Web now. Learn more and register at http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.com/ ___ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user I think BACK has to be only an undo process, and NEXT is the logical next state depending on the datas already collected. If 2 forms could result from an actual status, then you have to review the logical chain. my two cents :) Dominique Simonart -- SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, Nevada. The future of the web can't happen without you. Join us at MIX09 to help
[Gambas-user] Infinite loop with the image editor
Hi, May be it's me, but ... in the gambas 2.9 IDE (opensuse 11.0 KDE 3, Qt project), create a new image1.png file. after drawing something on the area, select the transparent color and the fill tool then click on a colored pixel and you enter in infinite loop. By the way, I search a solution to restore a small area in a big picture with transparency. How this is possible? regards, Dominique SIMONART -- SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, Nevada. The future of the web can't happen without you. Join us at MIX09 to help pave the way to the Next Web now. Learn more and register at http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.com/ ___ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user