From ea7dfh at ...2382... Wed Sep 1 00:54:03 2010 From: ea7dfh at ...2382... (EA7DFH) Date: Wed, 01 Sep 2010 00:54:03 +0200 Subject: [Gambas-user] Controls by code are invisible in Gnome In-Reply-To: References: Message-ID: <4C7D880B.8020009@...2382...> El 31/08/10 22:50, Fabi??n Flores Vadell escribi??: I was testing a custom control in a Ubuntu 9.10 virtualized by VirtualBox (using Gambas 2.18), and my controls become invisible in execution time. This not happens on Kubuntu 10.04 on virtualbox too (using Gambas 2.20). I was suprized when I verified that the same happens with controls provided by Gambas, What's could be happening? 'lbl1 is invisible in time execution PUBLIC SUB _new() DIM lbl1 AS NEW Label(ME) lbl1.Text = "Hi people" END You forgot to mention this only happens when using gb.gui in Gnome or gb.gtk specifically. Regards, -- Jesus Guardon From ea7dfh at ...2382... Wed Sep 1 01:11:35 2010 From: ea7dfh at ...2382... (EA7DFH) Date: Wed, 01 Sep 2010 01:11:35 +0200 Subject: [Gambas-user] Controls by code are invisible in Gnome In-Reply-To: References: Message-ID: <4C7D8C27.70706@...2382...> El 31/08/10 22:50, Fabi?n Flores Vadell escribi?: > I was testing a custom control in a Ubuntu 9.10 virtualized by > VirtualBox (using Gambas 2.18), and my controls become invisible in > execution time. This not happens on Kubuntu 10.04 on virtualbox too > (using Gambas 2.20). > > I was suprized when I verified that the same happens with controls > provided by Gambas, What's could be happening? > > 'lbl1 is invisible in time execution > PUBLIC SUB _new() > DIM lbl1 AS NEW Label(ME) > > lbl1.Text = "Hi people" > END > Sorry for re-posting... I've clicked the Send button too early! May be you need to specify X, Y coordinates and size for the new widget to be positioned on your form? -- Jesus, EA7DFH From fabianfloresvadell at ...626... Wed Sep 1 02:06:56 2010 From: fabianfloresvadell at ...626... (=?ISO-8859-1?Q?Fabi=E1n_Flores_Vadell?=) Date: Tue, 31 Aug 2010 21:06:56 -0300 Subject: [Gambas-user] Controls by code are invisible in Gnome In-Reply-To: <4C7D8C27.70706@...2382...> References: <4C7D8C27.70706@...2382...> Message-ID: 2010/8/31 EA7DFH : > You forgot to mention this only happens when using gb.gui in Gnome or gb.gtk > specifically. Thanks for the correction. > Sorry for re-posting... I've clicked the Send button too early! > > May be you need to specify X, Y coordinates and size for the new widget > to be positioned on your form? I tried that, but isn't the problem. -- Fabi?n Flores Vadell www.speedbooksargentina.blogspot.com From robert1juhasz at ...626... Wed Sep 1 09:49:08 2010 From: robert1juhasz at ...626... (JUHASZ Robert) Date: Wed, 01 Sep 2010 09:49:08 +0200 Subject: [Gambas-user] TableView issue In-Reply-To: <201008301646.14018.gambas@...1...> References: <201008301514.24979.gambas@...1...> <201008301646.14018.gambas@...1...> Message-ID: <1283327348.1808.11.camel@...2425...> Benoit, I just updated to the 2.21 version, revision 3173. Checking with the previously attached file gives the same behavior :-( Did I do something wrong with the update or the bug survived ? Robi -----Original Message----- From: Beno?t Minisini Reply-to: mailing list for gambas users To: mailing list for gambas users Subject: Re: [Gambas-user] TableView issue Date: Mon, 30 Aug 2010 16:46:13 +0200 > > Hello List, > > > > I found a strange behavior of the tableview control. I use Gambas 2.20, > > qt, on ubuntu 10.04. > > > > I try to create an editable table. > > As long as I use only text input, it works fine. > > As long as I use lists or text and list but with unprotected > > (readonly=false, as by default) lists, it works fine. In this case I can > > use the arrows to move up and down, left and right. It is very > > comfortable. As long as I use protected lists (readonly=true) it works > > fine as well, except that I cannot move left and right with the arrows. > > It is less comfortable but still okay. > > > > The problem comes when I use some columns with protected and some others > > with unprotected lists. > > In this case, when I use the arrows for moving horizontally and I move > > from an unprotected cell to a protected one, it crashes the code with an > > error message about the combo box. > > > > If I was not clear then take the attached code, select a cell and move by > > pressing the arrows. The middle column is "unprotected". > > > > > > Can someone tell me if it's a bug or what should I do different? > > > > Thx, > > Robi > > This was a bug! Can you try the revision #3162 to tell me if it works > better for you? No, try revision #3164 instead, it is better. :-) From fabianfloresvadell at ...626... Wed Sep 1 14:24:51 2010 From: fabianfloresvadell at ...626... (=?ISO-8859-1?Q?Fabi=E1n_Flores_Vadell?=) Date: Wed, 1 Sep 2010 09:24:51 -0300 Subject: [Gambas-user] Inconsistent initialization in controls: seems a little bug Message-ID: I tested this only for control Label: When a control label is created in execution time using gb.qt, then control become visible just after assign a value at the Text property: PUBLIC SUB _New() DIM lbl1 AS NEW Label(ME) lbl1.Text = "Hi people" END But if you write the same code in a form using gb.gtk, the control Label keeps invisible until the properties X, Y, Width and Height gets values. -- Fabi?n Flores Vadell www.speedbooksargentina.blogspot.com From gambas at ...1... Wed Sep 1 19:45:14 2010 From: gambas at ...1... (=?utf-8?q?Beno=C3=AEt_Minisini?=) Date: Wed, 1 Sep 2010 19:45:14 +0200 Subject: [Gambas-user] Inconsistent initialization in controls: seems a little bug In-Reply-To: References: Message-ID: <201009011945.14184.gambas@...1...> > I tested this only for control Label: > > When a control label is created in execution time using gb.qt, then > control become visible just after assign a value at the Text property: > > PUBLIC SUB _New() > > DIM lbl1 AS NEW Label(ME) > > lbl1.Text = "Hi people" > > END > > But if you write the same code in a form using gb.gtk, the control > Label keeps invisible until the properties X, Y, Width and Height gets > values. I'm inclined to prefer the gb.gtk behaviour than the gb.qt one, aren't you? -- Beno?t Minisini From gambas at ...1... Wed Sep 1 19:46:35 2010 From: gambas at ...1... (=?utf-8?q?Beno=C3=AEt_Minisini?=) Date: Wed, 1 Sep 2010 19:46:35 +0200 Subject: [Gambas-user] TableView issue In-Reply-To: <1283327348.1808.11.camel@...2425...> References: <201008301646.14018.gambas@...1...> <1283327348.1808.11.camel@...2425...> Message-ID: <201009011946.35390.gambas@...1...> > Benoit, > > I just updated to the 2.21 version, revision 3173. > Checking with the previously attached file gives the same behavior :-( > > Did I do something wrong with the update or the bug survived ? > > Robi > Are you sure that you recompile things correctly? I have tested with the example you provided me. -- Beno?t Minisini From gambas at ...1... Wed Sep 1 19:47:59 2010 From: gambas at ...1... (=?utf-8?q?Beno=C3=AEt_Minisini?=) Date: Wed, 1 Sep 2010 19:47:59 +0200 Subject: [Gambas-user] TableView issue In-Reply-To: <201009011946.35390.gambas@...1...> References: <1283327348.1808.11.camel@...2425...> <201009011946.35390.gambas@...1...> Message-ID: <201009011948.00011.gambas@...1...> > > Benoit, > > > > I just updated to the 2.21 version, revision 3173. > > Checking with the previously attached file gives the same behavior :-( > > > > Did I do something wrong with the update or the bug survived ? > > > > Robi > > Are you sure that you recompile things correctly? I have tested with the > example you provided me. Sorry, I didn't see that with gb.gtk there is another problem! -- Beno?t Minisini From gambas at ...1... Wed Sep 1 22:02:24 2010 From: gambas at ...1... (=?utf-8?q?Beno=C3=AEt_Minisini?=) Date: Wed, 1 Sep 2010 22:02:24 +0200 Subject: [Gambas-user] TableView issue In-Reply-To: <201009011948.00011.gambas@...1...> References: <201009011946.35390.gambas@...1...> <201009011948.00011.gambas@...1...> Message-ID: <201009012202.24603.gambas@...1...> > > > Benoit, > > > > > > I just updated to the 2.21 version, revision 3173. > > > Checking with the previously attached file gives the same behavior :-( > > > > > > Did I do something wrong with the update or the bug survived ? > > > > > > Robi > > > > Are you sure that you recompile things correctly? I have tested with the > > example you provided me. > > Sorry, I didn't see that with gb.gtk there is another problem! Is it better with revision #3174? -- Beno?t Minisini From dag.jarle.johansen at ...2312... Wed Sep 1 23:19:30 2010 From: dag.jarle.johansen at ...2312... (Dag Jarle Johansen) Date: Wed, 1 Sep 2010 18:19:30 -0300 Subject: [Gambas-user] Your energy In-Reply-To: <201009012202.24603.gambas@...1...> References: <201009011946.35390.gambas@...1...> <201009011948.00011.gambas@...1...> <201009012202.24603.gambas@...1...> Message-ID: Hola, Benoit. this is no mail because of things not happening - this is a mail of admiretance, I was a little silent in the last months, because I have to write some stuff in PHP. Facebook-stuff MS I hate it, but that is money. Plenty. I really even have to do it, but I see it as a challenge - old guy making young people happy. Now to Gambas - JUST GREAT - in every means - how do manage that? How do you at all manage all that mails? You are so fast in everything you are doing, I am very impressed. Saludos, Dag From fabianfloresvadell at ...626... Thu Sep 2 01:03:06 2010 From: fabianfloresvadell at ...626... (=?ISO-8859-1?Q?Fabi=E1n_Flores_Vadell?=) Date: Wed, 1 Sep 2010 20:03:06 -0300 Subject: [Gambas-user] Inconsistent initialization in controls: seems a little bug In-Reply-To: <201009011945.14184.gambas@...1...> References: <201009011945.14184.gambas@...1...> Message-ID: 2010/9/1 Beno?t Minisini : > I'm inclined to prefer the gb.gtk behaviour than the gb.qt one, aren't you? Uhm... when a label is drawed on a form by double clicking on its icon in the toolbox, the label appears on X=0 Y=0, its Text property is set to "LabelX" and its Width adjusts to Text property. I think than this behavior should be consistent with the initialization that take place when controls are created by code, too. I think that if the behavior is consistent, choose by one or another isn't significant for programmers. But student or begginers may be keeps in their retinas the behavior that they saw when creating controls on the form editor, and they expect that the same happens when they create controls by code. My preference is to the more intuitive behavior... that seems to me is the gb.qt. Thanks for consider my opinion. -- Fabi?n Flores Vadell www.speedbooksargentina.blogspot.com From robert1juhasz at ...626... Thu Sep 2 10:03:26 2010 From: robert1juhasz at ...626... (JUHASZ Robert) Date: Thu, 02 Sep 2010 10:03:26 +0200 Subject: [Gambas-user] TableView issue In-Reply-To: <201009012202.24603.gambas@...1...> References: <201009011946.35390.gambas@...1...> <201009011948.00011.gambas@...1...> <201009012202.24603.gambas@...1...> Message-ID: <1283414606.1665.10.camel@...2425...> Salut Benoit, I tested the last version with the different components: gb.qt: still the same problem (ComboBox is read-only) gb.qtk: OK gb.gui: OK I use gb.qt. Robi -----Original Message----- From: Beno?t Minisini Reply-to: mailing list for gambas users To: mailing list for gambas users Subject: Re: [Gambas-user] TableView issue Date: Wed, 1 Sep 2010 22:02:24 +0200 > > > Benoit, > > > > > > I just updated to the 2.21 version, revision 3173. > > > Checking with the previously attached file gives the same behavior :-( > > > > > > Did I do something wrong with the update or the bug survived ? > > > > > > Robi > > > > Are you sure that you recompile things correctly? I have tested with the > > example you provided me. > > Sorry, I didn't see that with gb.gtk there is another problem! Is it better with revision #3174? From doriano.blengino at ...1909... Thu Sep 2 10:21:23 2010 From: doriano.blengino at ...1909... (Doriano Blengino) Date: Thu, 02 Sep 2010 10:21:23 +0200 Subject: [Gambas-user] Inconsistent initialization in controls: seems a little bug In-Reply-To: References: <201009011945.14184.gambas@...1...> Message-ID: <4C7F5E83.8000503@...1909...> Fabi?n Flores Vadell ha scritto: > 2010/9/1 Beno?t Minisini : > >> I'm inclined to prefer the gb.gtk behaviour than the gb.qt one, aren't you? >> > > Uhm... when a label is drawed on a form by double clicking on its icon > in the toolbox, the label appears on X=0 Y=0, its Text property is set > to "LabelX" and its Width adjusts to Text property. I think than this > behavior should be consistent with the initialization that take place > when controls are created by code, too. > I agree - consistency; but the center question is the AutoResize property. If it is true by default, then the widget should show as soon as its text property is set to something "visible". If it is false, then the widget should not resize and, doing so, it should keep its default size. If its default size is zero, then the widget is invisible. The Autoresize seems to default to false, so gtk seems more logical. Anyway, I believe that interactive editing of a form, and creatiaon of controls by code, are two different situations, with different requirements. Consistency is desirable, if it does not clash with something else more important. Regards, Doriano > I think that if the behavior is consistent, choose by one or another > isn't significant for programmers. But student or begginers may be > keeps in their retinas the behavior that they saw when creating > controls on the form editor, and they expect that the same happens > when they create controls by code. > > My preference is to the more intuitive behavior... that seems to me is > the gb.qt. > > Thanks for consider my opinion. > > > From eilert-sprachen at ...221... Thu Sep 2 10:39:51 2010 From: eilert-sprachen at ...221... (Rolf-Werner Eilert) Date: Thu, 02 Sep 2010 10:39:51 +0200 Subject: [Gambas-user] How to realize AND, OR etc. Message-ID: <4C7F62D7.9060706@...221...> This is just a general question about programming, it doesn't refer to Gambas specifically, but I would implement the results in Gambas. For some of my bigger projects I have had to implement IF and ELSE and similar functions. I tried to manage AND, OR etc. too, but I failed. Somehow I didn't find a proper way of implementing this logic. So up to now I have filled this gap by simply putting several IF ELSE IF ELSE and so on within each other. Of course this is somewhat tricky sometimes :-) Could someone here explain me how an AND and an OR can be implemented? Are there general rules? I do not need the parser, it is there. I just ask about the logic behind AND and OR for instance. Here are my thoughts so far: - Parser puts IF-clauses into array and logic (AND/OR) in between or into separate list - IF-clauses are solved and results are stored e. g. in a boolean array - The ANDs and ORs from the list are processed with the boolean array into a final result This does not, however, include looking for bracketed clauses... Oh my goodness :-) Thanks for your help... Regards Rolf From wdahn at ...1000... Thu Sep 2 11:20:10 2010 From: wdahn at ...1000... (Werner) Date: Thu, 02 Sep 2010 17:20:10 +0800 Subject: [Gambas-user] How to realize AND, OR etc. In-Reply-To: <4C7F62D7.9060706@...221...> References: <4C7F62D7.9060706@...221...> Message-ID: <4C7F6C4A.2020103@...1000...> On 02/09/10 16:39, Rolf-Werner Eilert wrote: > This is just a general question about programming, it doesn't refer to > Gambas specifically, but I would implement the results in Gambas. > > For some of my bigger projects I have had to implement IF and ELSE and > similar functions. I tried to manage AND, OR etc. too, but I failed. > Somehow I didn't find a proper way of implementing this logic. So up to > now I have filled this gap by simply putting several IF ELSE IF ELSE and > so on within each other. Of course this is somewhat tricky sometimes :-) > > Could someone here explain me how an AND and an OR can be implemented? > Are there general rules? I do not need the parser, it is there. I just > ask about the logic behind AND and OR for instance. > > Here are my thoughts so far: > > - Parser puts IF-clauses into array and logic (AND/OR) in between or > into separate list > > - IF-clauses are solved and results are stored e. g. in a boolean array > > - The ANDs and ORs from the list are processed with the boolean array > into a final result > > This does not, however, include looking for bracketed clauses... Oh my > goodness :-) > > Thanks for your help... > > Regards > > Rolf > No sweat, it's just Ones and Zeroes... :-D It is not very clear (to me) what you actually want to achieve. You might want to take a closer look at the SELECT statement. It takes a lot of clutter out of code. Regards Werner From doriano.blengino at ...1909... Thu Sep 2 11:36:24 2010 From: doriano.blengino at ...1909... (Doriano Blengino) Date: Thu, 02 Sep 2010 11:36:24 +0200 Subject: [Gambas-user] How to realize AND, OR etc. In-Reply-To: <4C7F62D7.9060706@...221...> References: <4C7F62D7.9060706@...221...> Message-ID: <4C7F7018.1080109@...1909...> Rolf-Werner Eilert ha scritto: > This is just a general question about programming, it doesn't refer to > Gambas specifically, but I would implement the results in Gambas. > > For some of my bigger projects I have had to implement IF and ELSE and > similar functions. I tried to manage AND, OR etc. too, but I failed. > Somehow I didn't find a proper way of implementing this logic. So up to > now I have filled this gap by simply putting several IF ELSE IF ELSE and > so on within each other. Of course this is somewhat tricky sometimes :-) > > Could someone here explain me how an AND and an OR can be implemented? > Are there general rules? I do not need the parser, it is there. I just > ask about the logic behind AND and OR for instance. > > Here are my thoughts so far: > > - Parser puts IF-clauses into array and logic (AND/OR) in between or > into separate list > > - IF-clauses are solved and results are stored e. g. in a boolean array > > - The ANDs and ORs from the list are processed with the boolean array > into a final result > > This does not, however, include looking for bracketed clauses... Oh my > goodness :-) > Generally speaking, compilers (or parsers) don't use arrays to store intermediate results. ANDs and ORs are like any other arithmetic operation - they are evaluated left to right, giving precedence when due. But! Especially when speaking about boolean expressions, you can't assume a specific order of evaluation. Some compiler can even arrange code in such a manner that some computation is be omitted, when at a certain point of the expression the result is already known. This is called short-circuit, and Gambas does *not* use it. To clarify, if I write: IF A > 3 AND B+5 > 2 THEN... some runtime could evaluate "A > 3" and, if it founds it false, completely avoid to compute "b+5" and "B+5 > 2". Gambas does never do so. It evaluates "A > 3", obtaining a true/false value. Then it computes "B+5", compares with 2, and obtains another true/false value. Then it computes the AND between the two boolean values, and so it can decide to execute the THEN part or not. Again, you should not rely on a specific order of execution; the same as with any other arithmetic calculus: you can only tell that "B+5" is evaluated before "B+5>3", because the greater-than has a lower precedence. But then, you don't know if the first comparison is computed before or after the second. All this is important if, when evaluating expressions, some collateral result is expected. If, instead evaluating simple variables, you use properties or function calls and, if these properties or function calls do something behind the scenes (some collateral effect), then the order of evaluation can be important, but you should not rely on it. The solution in this case is to use temporary boolean variables to force the evaluation of some piece of code, and have a predictable evaluation order. The line of code above could be written like: btemp1 = A > 3 btemp2 = B+5 > 2 IF btemp1 and btemp2 THEN... This version of code assures that A and B are always evaluated, and in that given order. That said, when there is more than one possibility, it's a question of style. I personally don't like long sequences of ANDs and ORs, but sometimes they are expressive: IF age<18 or sex=female or state=married or religion<>catholic THEN you_are_not_a_catholic_priest() To make the long line above a little shorter, one could use multi-line IFs, or one could deploy temporary variables, but in this case the line: btemp1 = age<18 or religion<>catholic what does mean? Do we have a name for persons which are "minors or not catholic"? This code is not self-explanatory, and so it is ugly. Hope this helps a little, Regards Doriano From wdahn at ...1000... Thu Sep 2 11:52:07 2010 From: wdahn at ...1000... (Werner) Date: Thu, 02 Sep 2010 17:52:07 +0800 Subject: [Gambas-user] Bitwise Operations Wish Message-ID: <4C7F73C7.4000202@...1000...> There were days when binary values were actually represented in bits within a byte or word. This is still true when interfacing to some boxes such as PLCs. Likewise, some operations - eg calculating a CRC - are very awkward to implement without bitwise operations. It would be really nice to have this functionality. Anyone who has ever programmed in Assembler propably knows what I mean. The following would be a fairly complete set, I think: BitAnd( a AS Expression, b AS Expression) AS Expression BitOr( a AS Expression, b AS Expression) AS Expression BitXOr( a AS Expression, b AS Expression) AS Expression BitNot( a AS Expression) AS Expression BitShift( a AS Expression, count as Byte) AS Expression BitRotate( a AS Expression, count as Byte) AS Expression where Expression boils down to one of the following: Byte Short Integer Long If expressions a and b are not the same size the shorter one needs to be expanded with zeroes (MSB side) to match. Regards Werner From eilert-sprachen at ...221... Thu Sep 2 11:55:20 2010 From: eilert-sprachen at ...221... (Rolf-Werner Eilert) Date: Thu, 02 Sep 2010 11:55:20 +0200 Subject: [Gambas-user] How to realize AND, OR etc. In-Reply-To: <4C7F6C4A.2020103@...1000...> References: <4C7F62D7.9060706@...221...> <4C7F6C4A.2020103@...1000...> Message-ID: <4C7F7488.6050304@...221...> Am 02.09.2010 11:20, schrieb Werner: > On 02/09/10 16:39, Rolf-Werner Eilert wrote: >> This is just a general question about programming, it doesn't refer to >> Gambas specifically, but I would implement the results in Gambas. >> >> For some of my bigger projects I have had to implement IF and ELSE and >> similar functions. I tried to manage AND, OR etc. too, but I failed. >> Somehow I didn't find a proper way of implementing this logic. So up to >> now I have filled this gap by simply putting several IF ELSE IF ELSE and >> so on within each other. Of course this is somewhat tricky sometimes :-) >> >> Could someone here explain me how an AND and an OR can be implemented? >> Are there general rules? I do not need the parser, it is there. I just >> ask about the logic behind AND and OR for instance. >> >> Here are my thoughts so far: >> >> - Parser puts IF-clauses into array and logic (AND/OR) in between or >> into separate list >> >> - IF-clauses are solved and results are stored e. g. in a boolean array >> >> - The ANDs and ORs from the list are processed with the boolean array >> into a final result >> >> This does not, however, include looking for bracketed clauses... Oh my >> goodness :-) >> >> Thanks for your help... >> >> Regards >> >> Rolf >> > No sweat, it's just Ones and Zeroes... :-D > > It is not very clear (to me) what you actually want to achieve. > You might want to take a closer look at the SELECT statement. It takes a > lot of clutter out of code. > > Regards > Werner SELECT is just another view to IF (a somewhat limited version) I'd say. No, my question was: How can I implement such a logic in my own program? Regards Rolf From gambas.fr at ...626... Thu Sep 2 12:39:28 2010 From: gambas.fr at ...626... (Fabien Bodard) Date: Thu, 2 Sep 2010 12:39:28 +0200 Subject: [Gambas-user] How to realize AND, OR etc. In-Reply-To: <4C7F7488.6050304@...221...> References: <4C7F62D7.9060706@...221...> <4C7F6C4A.2020103@...1000...> <4C7F7488.6050304@...221...> Message-ID: > No, my question was: How can I implement such a logic in my own program? did you try to make a kind of high level interpreter ? for macro for exemple ? if it is that ... the doriano explanation is good :) From eilert-sprachen at ...221... Thu Sep 2 12:40:38 2010 From: eilert-sprachen at ...221... (Rolf-Werner Eilert) Date: Thu, 02 Sep 2010 12:40:38 +0200 Subject: [Gambas-user] How to realize AND, OR etc. In-Reply-To: <4C7F7018.1080109@...1909...> References: <4C7F62D7.9060706@...221...> <4C7F7018.1080109@...1909...> Message-ID: <4C7F7F26.9070202@...221...> Am 02.09.2010 11:36, schrieb Doriano Blengino: > Rolf-Werner Eilert ha scritto: >> This is just a general question about programming, it doesn't refer to >> Gambas specifically, but I would implement the results in Gambas. >> >> For some of my bigger projects I have had to implement IF and ELSE and >> similar functions. I tried to manage AND, OR etc. too, but I failed. >> Somehow I didn't find a proper way of implementing this logic. So up to >> now I have filled this gap by simply putting several IF ELSE IF ELSE and >> so on within each other. Of course this is somewhat tricky sometimes :-) >> >> Could someone here explain me how an AND and an OR can be implemented? >> Are there general rules? I do not need the parser, it is there. I just >> ask about the logic behind AND and OR for instance. >> >> Here are my thoughts so far: >> >> - Parser puts IF-clauses into array and logic (AND/OR) in between or >> into separate list >> >> - IF-clauses are solved and results are stored e. g. in a boolean array >> >> - The ANDs and ORs from the list are processed with the boolean array >> into a final result >> >> This does not, however, include looking for bracketed clauses... Oh my >> goodness :-) >> Thanks for your comprehensive answer! Here are my thoughts: > Generally speaking, compilers (or parsers) don't use arrays to store > intermediate results. ANDs and ORs are like any other arithmetic > operation - they are evaluated left to right, giving precedence when > due. But! Especially when speaking about boolean expressions, you can't > assume a specific order of evaluation. Ok... But what about brackets? When the user of my program wants to make sure the expressions ARE evaluated in a special order? How does this fit in here? > Some compiler can even arrange > code in such a manner that some computation is be omitted, when at a > certain point of the expression the result is already known. This is > called short-circuit, and Gambas does *not* use it. To clarify, if I write: > > IF A> 3 AND B+5> 2 THEN... > > some runtime could evaluate "A> 3" and, if it founds it false, > completely avoid to compute "b+5" and "B+5> 2". Gambas does never do > so. And I would be glad if I managed my own program to be half as clever as Gambas is :-) > It evaluates "A> 3", obtaining a true/false value. Then it computes > "B+5", compares with 2, and obtains another true/false value. Then it > computes the AND between the two boolean values, and so it can decide to > execute the THEN part or not. Yep - and how does it organize this? Doesn't it have to look into the whole line prior to seeing that there is a "> 2" following in order to decide to compute "B+5" first? And doesn't it have to evaluate "A > 3" and "B + 5 > 2" prior to computing the AND? So everything has to be put apart into certain pieces, then evaluated, computed and so on to get a final result. If there's no array way of doing it - how is it done then? If I go letter-by-letter through the formula text the user of my program is giving me, I might at every moment stumble over new surprises :-) > All this is important if, when evaluating expressions, some collateral > result is expected. If, instead evaluating simple variables, you use > properties or function calls and, if these properties or function calls > do something behind the scenes (some collateral effect), then the order > of evaluation can be important, but you should not rely on it. As far as I can see, I wouldn't risk collateral results in my programs. > The > solution in this case is to use temporary boolean variables to force the > evaluation of some piece of code, and have a predictable evaluation > order. The line of code above could be written like: > > btemp1 = A> 3 > btemp2 = B+5> 2 > IF btemp1 and btemp2 THEN... This would make up for a nice array, wouldn't it? :-) > > This version of code assures that A and B are always evaluated, and in > that given order. > > That said, when there is more than one possibility, it's a question of > style. I personally don't like long sequences of ANDs and ORs, but > sometimes they are expressive: > > IF age<18 or sex=female or state=married or religion<>catholic THEN > you_are_not_a_catholic_priest() Ok. Let's use my printing forms as an example. This is where my need for this kind of logic is most urgent. If I want to have a certificate printed for the number of language courses a student is taking, I have to decide how to use the free space for the marks. So if it's only 2 languages, there is more space and I can keep the places for the marks more apart than if it's 4 languages. So the line of code in the printing form could read somewhat like (I write pseudo code, that's easier here) IF Instr "courses" = "Spanish" AND Instr "courses" = "Russian" THEN print special 4 languages version ELSE IF Instr "courses" = "Spanish" OR Instr "courses" = "Russian" THEN print 3 languages version ELSE print 2 languages version Of course it is possible to do this without any ANDs and ORs, but it would make things easier to read. It is really complicated to read now. Another case which came about yesterday and reminded me to this whole thing: For example, if a student has booked a certain main course which is more expensive than the ordinary one but then books in for another special language course, there will be a discount on the main course. If I have to indicate on a sheet how much the students pay, I have to decide: IF expensive main course THEN IF plus special course THEN x Euros for main course z Euros for special course ELSE y Euros for main course only END IF ELSE x Euros for main course IF special course booked THEN z Euros for special course END IF END IF If there were ANDs and ORs it would make life somewhat easier ;-) Furthermore, there are other places in the program where a logical sequence with ANDs and ORs could help, and if I managed to program the whole thing in a way to be able to use it everywhere, this would open more ways of organisation. There is a filter function for instance to build lists of students in different classes and courses. It is very primitive now, it can only look for Instr in a single field, then put the name into the list or not. If I could use genuine logic, many things would be easier. Hope I could make this clearer. Your answer already helped, but if using arrays is unusual, which way is better then? Regards Rolf From eilert-sprachen at ...221... Thu Sep 2 12:48:43 2010 From: eilert-sprachen at ...221... (Rolf-Werner Eilert) Date: Thu, 02 Sep 2010 12:48:43 +0200 Subject: [Gambas-user] How to realize AND, OR etc. In-Reply-To: References: <4C7F62D7.9060706@...221...> <4C7F6C4A.2020103@...1000...> <4C7F7488.6050304@...221...> Message-ID: <4C7F810B.50608@...221...> Am 02.09.2010 12:39, schrieb Fabien Bodard: >> No, my question was: How can I implement such a logic in my own program? > > did you try to make a kind of high level interpreter ? for macro for exemple ? > > if it is that ... the doriano explanation is good :) > Yes, right that :-) And see my answer to him 5 minutes ago... From doriano.blengino at ...1909... Thu Sep 2 13:58:42 2010 From: doriano.blengino at ...1909... (Doriano Blengino) Date: Thu, 02 Sep 2010 13:58:42 +0200 Subject: [Gambas-user] How to realize AND, OR etc. In-Reply-To: <4C7F7F26.9070202@...221...> References: <4C7F62D7.9060706@...221...> <4C7F7018.1080109@...1909...> <4C7F7F26.9070202@...221...> Message-ID: <4C7F9172.8020603@...1909...> Rolf-Werner Eilert ha scritto: > Am 02.09.2010 11:36, schrieb Doriano Blengino: > >> Rolf-Werner Eilert ha scritto: >> >>> This is just a general question about programming, it doesn't refer to >>> Gambas specifically, but I would implement the results in Gambas. >>> >>> For some of my bigger projects I have had to implement IF and ELSE and >>> similar functions. I tried to manage AND, OR etc. too, but I failed. >>> Somehow I didn't find a proper way of implementing this logic. So up to >>> now I have filled this gap by simply putting several IF ELSE IF ELSE and >>> so on within each other. Of course this is somewhat tricky sometimes :-) >>> >>> I am not really sure about what you want. My first guess was that you wanted more information on *how* to use ANDs and ORs in a gambas program (and there are also XORs and NOTs). Now I doubt that you want to write a compiler able to interpret boolean expressions. I will try to explain a little below. > >> Generally speaking, compilers (or parsers) don't use arrays to store >> intermediate results. ANDs and ORs are like any other arithmetic >> operation - they are evaluated left to right, giving precedence when >> due. But! Especially when speaking about boolean expressions, you can't >> assume a specific order of evaluation. >> > > Ok... But what about brackets? When the user of my program wants to make > sure the expressions ARE evaluated in a special order? How does this fit > in here? > Brackets only force precedence in the classic way: 2*3+4 -> left to right, because "+" has lower precedence than "*" 2+3*4 -> first "3*4", because "*" has higher precedence than "+" (2+3)*4 -> again left to right, because the brackets. > >> Some compiler can even arrange >> code in such a manner that some computation is be omitted, when at a >> certain point of the expression the result is already known. This is >> called short-circuit, and Gambas does *not* use it. To clarify, if I write: >> >> IF A> 3 AND B+5> 2 THEN... >> >> some runtime could evaluate "A> 3" and, if it founds it false, >> completely avoid to compute "b+5" and "B+5> 2". Gambas does never do >> so. >> > > And I would be glad if I managed my own program to be half as clever as > Gambas is :-) > > > >> It evaluates "A> 3", obtaining a true/false value. Then it computes >> "B+5", compares with 2, and obtains another true/false value. Then it >> computes the AND between the two boolean values, and so it can decide to >> execute the THEN part or not. >> > > Yep - and how does it organize this? Doesn't it have to look into the > whole line prior to seeing that there is a "> 2" following in order to > decide to compute "B+5" first? And doesn't it have to evaluate "A > 3" > and "B + 5 > 2" prior to computing the AND? So everything has to be put > apart into certain pieces, then evaluated, computed and so on to get a > final result. > > If there's no array way of doing it - how is it done then? > > If I go letter-by-letter through the formula text the user of my program > is giving me, I might at every moment stumble over new surprises :-) > Actually you use a stack, which can also be seen as an array (unlimited array) with an index pointing in it. An expression starts with a "value", followed by a number of couples of "operator-next_value". You read the first value, which is "result". Then you read the next couple of "operator-value". If there is nothing more, you evaluate "result operator value" and finish. If there is something more, peek further at the next "operator2". If it has lower precedence than the current operator, you evaluate the current step and go ahead. Otherwise, you add a position in the stack and store current result and current operator, set "result" equal to the current value and operator=operator2, and go on. This is a quick and very simplified form, which does not explain how to "pop" the stack, and does not manage unary operators (like NOT, unary minuses, and so on). I only have to add that if you encounter an opening bracket, all the contents of the bracket have to be regarded as a value. If you know the HP hand calculators, which use RPN method, you can see that that method is nothing else than this. To calculate: 2+3*6 you press in sequence "2" Enter "3" Enter "6" "x" "+". Each time you press Enter the stack is pushed. Each time you apply an operator, the stack is popped. This could be another way to implement an expression compiler... > >> All this is important if, when evaluating expressions, some collateral >> result is expected. If, instead evaluating simple variables, you use >> properties or function calls and, if these properties or function calls >> do something behind the scenes (some collateral effect), then the order >> of evaluation can be important, but you should not rely on it. >> > > As far as I can see, I wouldn't risk collateral results in my programs. > > >> The >> solution in this case is to use temporary boolean variables to force the >> evaluation of some piece of code, and have a predictable evaluation >> order. The line of code above could be written like: >> >> btemp1 = A> 3 >> btemp2 = B+5> 2 >> IF btemp1 and btemp2 THEN... >> > > This would make up for a nice array, wouldn't it? :-) > Yes... but only because we wanted to use an array. And anyway, at last the array is combined into an expression! The same would be; b1 = ... b2 = ... b3 = ... if b1 or b2 and b3 then... I mean: we can not get rid of the final expression, so an array does not help :-) > >> This version of code assures that A and B are always evaluated, and in >> that given order. >> >> That said, when there is more than one possibility, it's a question of >> style. I personally don't like long sequences of ANDs and ORs, but >> sometimes they are expressive: >> >> IF age<18 or sex=female or state=married or religion<>catholic THEN >> you_are_not_a_catholic_priest() >> > > Ok. Let's use my printing forms as an example. This is where my need for > this kind of logic is most urgent. > > If I want to have a certificate printed for the number of language > courses a student is taking, I have to decide how to use the free space > for the marks. So if it's only 2 languages, there is more space and I > can keep the places for the marks more apart than if it's 4 languages. > > So the line of code in the printing form could read somewhat like (I > write pseudo code, that's easier here) > > IF Instr "courses" = "Spanish" AND Instr "courses" = "Russian" THEN > print special 4 languages version > ELSE IF Instr "courses" = "Spanish" OR Instr "courses" = "Russian" THEN > print 3 languages version > ELSE > print 2 languages version > > Of course it is possible to do this without any ANDs and ORs, but it > would make things easier to read. It is really complicated to read now. > > Another case which came about yesterday and reminded me to this whole thing: > > For example, if a student has booked a certain main course which is more > expensive than the ordinary one but then books in for another special > language course, there will be a discount on the main course. > > If I have to indicate on a sheet how much the students pay, I have to > decide: > > IF expensive main course THEN > IF plus special course THEN > x Euros for main course > z Euros for special course > ELSE > y Euros for main course only > END IF > ELSE > x Euros for main course > IF special course booked THEN > z Euros for special course > END IF > END IF > > If there were ANDs and ORs it would make life somewhat easier ;-) > > Furthermore, there are other places in the program where a logical > sequence with ANDs and ORs could help, and if I managed to program the > whole thing in a way to be able to use it everywhere, this would open > more ways of organisation. > > There is a filter function for instance to build lists of students in > different classes and courses. It is very primitive now, it can only > look for Instr in a single field, then put the name into the list or > not. If I could use genuine logic, many things would be easier. > > Hope I could make this clearer. Your answer already helped, but if using > arrays is unusual, which way is better then? > Uhm... a few considerations. If you must implement boolean logic in your program, but you don't need to let your users input boolean expressions into your program: You should express a series of "rules" like: 1. Course cost is X 2. Special cost is Y (zero means no special course) 3. if X>expensive and Y<>0 then X=X-discount 4. Total cost is X+Y or, 1. Course cost is X 2. Special cost is Y 3. Discount_applied = X>expensive and Y<>0 4. if Discount_applied then X=X-discount 5. print "Total cost is " X+Y 6. if Discount_applied then print "(discount)" Anyway, there is no single way to organize tests (IFs, AND, NOTs...) - we could read hundreds of different books on the same argument. But you was true when about gambas you wrote "look at the whole line". You should collect all the possible data, and group them in temporary (better say high level) variables, like "Discount_applied". Examine every rule one after another. Your rule is "If the main course is expensive, and there is another course, then there is a discount". Ok. Now suppose that now, or in the future, a new rule is added: "If the scholar is rich, then no discount can be applied". In a single piece of code, where you determine Discount_applied, you modify it: ... 3. Discount_applied = X>expensive and Y<>0 4. if Scholar_is_rich then Discount_applied = false ... May be that to determine if a scholar is rich you must examine the family income, and the number of members in the family... another piece of code that has a single purpose: determine the value of Scholar_is_rich. May be that you don't want to collect data about richness of scholars, if not needed (the scholar takes only one course). Then you must can do like this: ... 3. Discount_applied = X>expensive and Y<>0 4. Scholar_is_rich = false 4. if Discount_applied then calculate_if_scholar_is_reach() 5. if Scholar_is_rich then Discount_applied = false ... Another kind of problem is if you want to "interpret" boolean expressions inputted by users. Textual representation of boolean expressions is powerful, but can be difficult both to interpret and to input. A table can be easier: cond1 -and- cond2 -and- cond3 -and- cond4 -or- cond1 -and- cond2 -and- cond3 -and- cond4 -or- cond1 -and- cond2 -and- cond3 -and- cond4 The words "-and-" and "-or-" are fixed in the logic of the program; the size of the table is also fixed. Empty rows and empty fields are ignored. For every possible result (record), you start by saying "this record is ok". Then you scan all the rows, ignoring empty ones. If a row succeeds, the record passes. Every single row has 4 condition, which must be met all together. If one fails, the row fails. Every condition is a test in the form "value1 operator value2"; value1 is a combobox containing fields of the recors (name, surname, ZIP, course and so on); operator is a combobox containing "=", "<>". Value2 is inputted by the user. Try to use "Search messages..." in your email client (which is Thunderbird/Icedove, right? :-)). It does something very similar. I think to have been exhaustive... but if not, ask for more. Regards, Doriano From gambas at ...1... Thu Sep 2 14:06:30 2010 From: gambas at ...1... (=?utf-8?q?Beno=C3=AEt_Minisini?=) Date: Thu, 2 Sep 2010 14:06:30 +0200 Subject: [Gambas-user] Bitwise Operations Wish In-Reply-To: <4C7F73C7.4000202@...1000...> References: <4C7F73C7.4000202@...1000...> Message-ID: <201009021406.30064.gambas@...1...> > There were days when binary values were actually represented in bits > within a byte or word. This is still true when interfacing to some boxes > such as PLCs. > Likewise, some operations - eg calculating a CRC - are very awkward to > implement without bitwise operations. > > It would be really nice to have this functionality. Anyone who has ever > programmed in Assembler propably knows what I mean. > > The following would be a fairly complete set, I think: > > BitAnd( a AS Expression, b AS Expression) AS Expression -> a AND b > BitOr( a AS Expression, b AS Expression) AS Expression -> a OR b > BitXOr( a AS Expression, b AS Expression) AS Expression -> a XOR b > BitNot( a AS Expression) AS Expression -> NOT a > > BitShift( a AS Expression, count as Byte) AS Expression -> Lsl(a, count) -> Lsr(a, count) -> Asl(a, count) -> Asr(a, count) > BitRotate( a AS Expression, count as Byte) AS Expression -> Rol(a, count) -> Ror(a, count) > > where Expression boils down to one of the following: > Byte > Short > Integer > Long > > If expressions a and b are not the same size the shorter one needs to be > expanded with zeroes (MSB side) to match. That is what they do. Regards, -- Beno?t Minisini From wdahn at ...1000... Thu Sep 2 15:22:35 2010 From: wdahn at ...1000... (Werner) Date: Thu, 02 Sep 2010 21:22:35 +0800 Subject: [Gambas-user] Bitwise Operations Wish In-Reply-To: <201009021406.30064.gambas@...1...> References: <4C7F73C7.4000202@...1000...> <201009021406.30064.gambas@...1...> Message-ID: <4C7FA51B.8090608@...1000...> On 02/09/10 20:06, Beno?t Minisini wrote: >> There were days when binary values were actually represented in bits >> within a byte or word. This is still true when interfacing to some boxes >> such as PLCs. >> Likewise, some operations - eg calculating a CRC - are very awkward to >> implement without bitwise operations. >> >> It would be really nice to have this functionality. Anyone who has ever >> programmed in Assembler propably knows what I mean. >> >> The following would be a fairly complete set, I think: >> >> BitAnd( a AS Expression, b AS Expression) AS Expression >> > -> a AND b > > >> BitOr( a AS Expression, b AS Expression) AS Expression >> > -> a OR b > > >> BitXOr( a AS Expression, b AS Expression) AS Expression >> > -> a XOR b > > >> BitNot( a AS Expression) AS Expression >> > -> NOT a > > >> BitShift( a AS Expression, count as Byte) AS Expression >> > -> Lsl(a, count) > -> Lsr(a, count) > -> Asl(a, count) > -> Asr(a, count) > > >> BitRotate( a AS Expression, count as Byte) AS Expression >> > -> Rol(a, count) > -> Ror(a, count) > > >> where Expression boils down to one of the following: >> Byte >> Short >> Integer >> Long >> >> If expressions a and b are not the same size the shorter one needs to be >> expanded with zeroes (MSB side) to match. >> > That is what they do. > > Regards, > > Thanks, I was under the misguided impression these were for booleans. CHRISTMAS! :-) Werner From eilert-sprachen at ...221... Thu Sep 2 15:40:39 2010 From: eilert-sprachen at ...221... (Rolf-Werner Eilert) Date: Thu, 02 Sep 2010 15:40:39 +0200 Subject: [Gambas-user] How to realize AND, OR etc. In-Reply-To: <4C7F9172.8020603@...1909...> References: <4C7F62D7.9060706@...221...> <4C7F7018.1080109@...1909...> <4C7F7F26.9070202@...221...> <4C7F9172.8020603@...1909...> Message-ID: <4C7FA957.7000309@...221...> Am 02.09.2010 13:58, schrieb Doriano Blengino: > Rolf-Werner Eilert ha scritto: >> Am 02.09.2010 11:36, schrieb Doriano Blengino: >> >>> Rolf-Werner Eilert ha scritto: >>> >>>> This is just a general question about programming, it doesn't refer to >>>> Gambas specifically, but I would implement the results in Gambas. >>>> >>>> For some of my bigger projects I have had to implement IF and ELSE and >>>> similar functions. I tried to manage AND, OR etc. too, but I failed. >>>> Somehow I didn't find a proper way of implementing this logic. So up to >>>> now I have filled this gap by simply putting several IF ELSE IF ELSE and >>>> so on within each other. Of course this is somewhat tricky sometimes :-) >>>> >>>> > I am not really sure about what you want. My first guess was that you > wanted more information on *how* to use ANDs and ORs in a gambas program > (and there are also XORs and NOTs). Now I doubt that you want to write a > compiler able to interpret boolean expressions. I will try to explain a > little below. > >> >>> Generally speaking, compilers (or parsers) don't use arrays to store >>> intermediate results. ANDs and ORs are like any other arithmetic >>> operation - they are evaluated left to right, giving precedence when >>> due. But! Especially when speaking about boolean expressions, you can't >>> assume a specific order of evaluation. >>> >> >> Ok... But what about brackets? When the user of my program wants to make >> sure the expressions ARE evaluated in a special order? How does this fit >> in here? >> > Brackets only force precedence in the classic way: > > 2*3+4 -> left to right, because "+" has lower precedence than "*" > 2+3*4 -> first "3*4", because "*" has higher precedence than "+" > (2+3)*4 -> again left to right, because the brackets. > >> >>> Some compiler can even arrange >>> code in such a manner that some computation is be omitted, when at a >>> certain point of the expression the result is already known. This is >>> called short-circuit, and Gambas does *not* use it. To clarify, if I write: >>> >>> IF A> 3 AND B+5> 2 THEN... >>> >>> some runtime could evaluate "A> 3" and, if it founds it false, >>> completely avoid to compute "b+5" and "B+5> 2". Gambas does never do >>> so. >>> >> >> And I would be glad if I managed my own program to be half as clever as >> Gambas is :-) >> >> >> >>> It evaluates "A> 3", obtaining a true/false value. Then it computes >>> "B+5", compares with 2, and obtains another true/false value. Then it >>> computes the AND between the two boolean values, and so it can decide to >>> execute the THEN part or not. >>> >> >> Yep - and how does it organize this? Doesn't it have to look into the >> whole line prior to seeing that there is a "> 2" following in order to >> decide to compute "B+5" first? And doesn't it have to evaluate "A> 3" >> and "B + 5> 2" prior to computing the AND? So everything has to be put >> apart into certain pieces, then evaluated, computed and so on to get a >> final result. >> >> If there's no array way of doing it - how is it done then? >> >> If I go letter-by-letter through the formula text the user of my program >> is giving me, I might at every moment stumble over new surprises :-) >> > Actually you use a stack, which can also be seen as an array (unlimited > array) with an index pointing in it. > An expression starts with a "value", followed by a number of couples of > "operator-next_value". > You read the first value, which is "result". > Then you read the next couple of "operator-value". If there is nothing > more, you evaluate "result operator value" and finish. If there is > something more, peek further at the next "operator2". If it has lower > precedence than the current operator, you evaluate the current step and > go ahead. Otherwise, you add a position in the stack and store current > result and current operator, set "result" equal to the current value and > operator=operator2, and go on. > This is a quick and very simplified form, which does not explain how to > "pop" the stack, and does not manage unary operators (like NOT, unary > minuses, and so on). I only have to add that if you encounter an opening > bracket, all the contents of the bracket have to be regarded as a value. > If you know the HP hand calculators, which use RPN method, you can see > that that method is nothing else than this. To calculate: > > 2+3*6 > > you press in sequence "2" Enter "3" Enter "6" "x" "+". Each time you > press Enter the stack is pushed. Each time you apply an operator, the > stack is popped. > > This could be another way to implement an expression compiler... > >> >>> All this is important if, when evaluating expressions, some collateral >>> result is expected. If, instead evaluating simple variables, you use >>> properties or function calls and, if these properties or function calls >>> do something behind the scenes (some collateral effect), then the order >>> of evaluation can be important, but you should not rely on it. >>> >> >> As far as I can see, I wouldn't risk collateral results in my programs. >> >> >>> The >>> solution in this case is to use temporary boolean variables to force the >>> evaluation of some piece of code, and have a predictable evaluation >>> order. The line of code above could be written like: >>> >>> btemp1 = A> 3 >>> btemp2 = B+5> 2 >>> IF btemp1 and btemp2 THEN... >>> >> >> This would make up for a nice array, wouldn't it? :-) >> > Yes... but only because we wanted to use an array. And anyway, at last > the array is combined into an expression! > The same would be; > > b1 = ... > b2 = ... > b3 = ... > if b1 or b2 and b3 then... > > I mean: we can not get rid of the final expression, so an array does not > help :-) > >> >>> This version of code assures that A and B are always evaluated, and in >>> that given order. >>> >>> That said, when there is more than one possibility, it's a question of >>> style. I personally don't like long sequences of ANDs and ORs, but >>> sometimes they are expressive: >>> >>> IF age<18 or sex=female or state=married or religion<>catholic THEN >>> you_are_not_a_catholic_priest() >>> >> >> Ok. Let's use my printing forms as an example. This is where my need for >> this kind of logic is most urgent. >> >> If I want to have a certificate printed for the number of language >> courses a student is taking, I have to decide how to use the free space >> for the marks. So if it's only 2 languages, there is more space and I >> can keep the places for the marks more apart than if it's 4 languages. >> >> So the line of code in the printing form could read somewhat like (I >> write pseudo code, that's easier here) >> >> IF Instr "courses" = "Spanish" AND Instr "courses" = "Russian" THEN >> print special 4 languages version >> ELSE IF Instr "courses" = "Spanish" OR Instr "courses" = "Russian" THEN >> print 3 languages version >> ELSE >> print 2 languages version >> >> Of course it is possible to do this without any ANDs and ORs, but it >> would make things easier to read. It is really complicated to read now. >> >> Another case which came about yesterday and reminded me to this whole thing: >> >> For example, if a student has booked a certain main course which is more >> expensive than the ordinary one but then books in for another special >> language course, there will be a discount on the main course. >> >> If I have to indicate on a sheet how much the students pay, I have to >> decide: >> >> IF expensive main course THEN >> IF plus special course THEN >> x Euros for main course >> z Euros for special course >> ELSE >> y Euros for main course only >> END IF >> ELSE >> x Euros for main course >> IF special course booked THEN >> z Euros for special course >> END IF >> END IF >> >> If there were ANDs and ORs it would make life somewhat easier ;-) >> >> Furthermore, there are other places in the program where a logical >> sequence with ANDs and ORs could help, and if I managed to program the >> whole thing in a way to be able to use it everywhere, this would open >> more ways of organisation. >> >> There is a filter function for instance to build lists of students in >> different classes and courses. It is very primitive now, it can only >> look for Instr in a single field, then put the name into the list or >> not. If I could use genuine logic, many things would be easier. >> >> Hope I could make this clearer. Your answer already helped, but if using >> arrays is unusual, which way is better then? >> > Uhm... a few considerations. > > If you must implement boolean logic in your program, but you don't need > to let your users input boolean expressions into your program: > You should express a series of "rules" like: > > 1. Course cost is X > 2. Special cost is Y (zero means no special course) > 3. if X>expensive and Y<>0 then X=X-discount > 4. Total cost is X+Y > > or, > > 1. Course cost is X > 2. Special cost is Y > 3. Discount_applied = X>expensive and Y<>0 > 4. if Discount_applied then X=X-discount > 5. print "Total cost is " X+Y > 6. if Discount_applied then print "(discount)" > > Anyway, there is no single way to organize tests (IFs, AND, NOTs...) - > we could read hundreds of different books on the same argument. But you > was true when about gambas you wrote "look at the whole line". You > should collect all the possible data, and group them in temporary > (better say high level) variables, like "Discount_applied". Examine > every rule one after another. Your rule is "If the main course is > expensive, and there is another course, then there is a discount". Ok. > Now suppose that now, or in the future, a new rule is added: "If the > scholar is rich, then no discount can be applied". In a single piece of > code, where you determine Discount_applied, you modify it: > > ... > 3. Discount_applied = X>expensive and Y<>0 > 4. if Scholar_is_rich then Discount_applied = false > ... > > May be that to determine if a scholar is rich you must examine the > family income, and the number of members in the family... another piece > of code that has a single purpose: determine the value of > Scholar_is_rich. May be that you don't want to collect data about > richness of scholars, if not needed (the scholar takes only one course). > Then you must can do like this: > > ... > 3. Discount_applied = X>expensive and Y<>0 > 4. Scholar_is_rich = false > 4. if Discount_applied then calculate_if_scholar_is_reach() > 5. if Scholar_is_rich then Discount_applied = false > ... > > Another kind of problem is if you want to "interpret" boolean > expressions inputted by users. Textual representation of boolean > expressions is powerful, but can be difficult both to interpret and to > input. A table can be easier: > > cond1 -and- cond2 -and- cond3 -and- cond4 > -or- > cond1 -and- cond2 -and- cond3 -and- cond4 > -or- > cond1 -and- cond2 -and- cond3 -and- cond4 > > The words "-and-" and "-or-" are fixed in the logic of the program; the > size of the table is also fixed. > Empty rows and empty fields are ignored. For every possible result > (record), you start by saying "this record is ok". Then you scan all the > rows, ignoring empty ones. If a row succeeds, the record passes. > Every single row has 4 condition, which must be met all together. If one > fails, the row fails. > Every condition is a test in the form "value1 operator value2"; value1 > is a combobox containing fields of the recors (name, surname, ZIP, > course and so on); operator is a combobox containing "=", "<>". Value2 > is inputted by the user. > > Try to use "Search messages..." in your email client (which is > Thunderbird/Icedove, right? :-)). It does something very similar. > > I think to have been exhaustive... but if not, ask for more. > > Regards, > Doriano > Thank you very much, Doriano, this will help a lot. Especially the idea with the table was very enlighting. I guess I'll manage to fiddle together something like that. If there are more questions, I'll be back :-) Regards Rolf From jussi.lahtinen at ...626... Thu Sep 2 19:29:52 2010 From: jussi.lahtinen at ...626... (Jussi Lahtinen) Date: Thu, 2 Sep 2010 20:29:52 +0300 Subject: [Gambas-user] Your energy In-Reply-To: References: <201009011946.35390.gambas@...1...> <201009011948.00011.gambas@...1...> <201009012202.24603.gambas@...1...> Message-ID: True, maybe Benoit means twins in English! Jussi On Thu, Sep 2, 2010 at 00:19, Dag Jarle Johansen wrote: > Hola, Benoit. > > this is no mail because of things not happening - this is a mail of > admiretance, > I was a little silent in the last months, because I have to write some > stuff in PHP. Facebook-stuff MS I hate it, but that is money. Plenty. I > really even have to do it, but I see it as a challenge - old guy making > young people happy. > > Now to Gambas - JUST GREAT - in every means - how do manage that? > How do you at all manage all that mails? You are so fast in everything > you are doing, I am very impressed. > > Saludos, > Dag > > ------------------------------------------------------------------------------ > This SF.net Dev2Dev email is sponsored by: > > Show off your parallel programming skills. > Enter the Intel(R) Threading Challenge 2010. > http://p.sf.net/sfu/intel-thread-sfd > _______________________________________________ > Gambas-user mailing list > Gambas-user at lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/gambas-user > From gambas at ...1... Thu Sep 2 19:41:14 2010 From: gambas at ...1... (=?utf-8?q?Beno=C3=AEt_Minisini?=) Date: Thu, 2 Sep 2010 19:41:14 +0200 Subject: [Gambas-user] Your energy In-Reply-To: References: Message-ID: <201009021941.14146.gambas@...1...> > True, maybe Benoit means twins in English! > > Jussi > > Hey guys, my birthday is not now, just in four days! ;-) -- Beno?t Minisini From gambas.fr at ...626... Thu Sep 2 22:50:45 2010 From: gambas.fr at ...626... (Fabien Bodard) Date: Thu, 2 Sep 2010 22:50:45 +0200 Subject: [Gambas-user] TableView issue In-Reply-To: <1283414606.1665.10.camel@...2425...> References: <201009011946.35390.gambas@...1...> <201009011948.00011.gambas@...1...> <201009012202.24603.gambas@...1...> <1283414606.1665.10.camel@...2425...> Message-ID: 2010/9/2 JUHASZ Robert : > Salut Benoit, > > I tested the last version with the different components: > > gb.qt: still the same problem (ComboBox is read-only) > gb.qtk: OK gb.gui: OK ==> so you are in gnome :) > > I use gb.qt. > > Robi > > -----Original Message----- > From: Beno?t Minisini > Reply-to: mailing list for gambas users > > To: mailing list for gambas users > Subject: Re: [Gambas-user] TableView issue > Date: Wed, 1 Sep 2010 22:02:24 +0200 > > >> > > Benoit, >> > > >> > > I just updated to the 2.21 version, revision 3173. >> > > Checking with the previously attached file gives the same behavior :-( >> > > >> > > Did I do something wrong with the update or the bug survived ? >> > > >> > > Robi >> > >> > Are you sure that you recompile things correctly? I have tested with the >> > example you provided me. >> >> Sorry, I didn't see that with gb.gtk there is another problem! > > Is it better with revision #3174? > > ------------------------------------------------------------------------------ > This SF.net Dev2Dev email is sponsored by: > > Show off your parallel programming skills. > Enter the Intel(R) Threading Challenge 2010. > http://p.sf.net/sfu/intel-thread-sfd > _______________________________________________ > Gambas-user mailing list > Gambas-user at lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/gambas-user > From fabianfloresvadell at ...626... Thu Sep 2 23:43:34 2010 From: fabianfloresvadell at ...626... (=?ISO-8859-1?Q?Fabi=E1n_Flores_Vadell?=) Date: Thu, 2 Sep 2010 18:43:34 -0300 Subject: [Gambas-user] Inconsistent initialization in controls: seems a little bug In-Reply-To: <4C7F5E83.8000503@...1909...> References: <201009011945.14184.gambas@...1...> <4C7F5E83.8000503@...1909...> Message-ID: 2010/9/2 Doriano Blengino : > I agree - consistency; but the center question is the AutoResize > property. If it is true by default, then the widget should show as soon > as its text property is set to something "visible". If it is false, then > the widget should not resize and, doing so, it should keep its default > size. If its default size is zero, then the widget is invisible. The > Autoresize seems to default to false, so gtk seems more logical. I think that have no sense that a graphic object is initialized to (0,0,0,0), because make not sense that it become invisible in its initial state. There's no logic in that. The purpose of a control is showing something, so its initial state shouldn't be one that it become invisible. I think about this goal can be achieved by making TRUE the default value of AutoResize property in the control Label, that make sense especially in this case because Labels always should show the value of its Text property (show a half string o just a part make no sense. Right?). So, default AutoResize = False go against the purpose of the Label control. > Anyway, I believe that interactive editing of a form, and creatiaon of > controls by code, are two different situations, with different > requirements. Yes, they are two differents situations. But, what those diferent requirements? > Consistency is desirable, if it does not clash with > something else more important. I agree. But I don't see clash between consistency and anything else in this case. Consistency matters because allow predict behaviors, but never can go against the logical behavior of a object. So in this case consistency and logical behavior of the control Label match, if the default value to AutoResize is TRUE. Regards. -- Fabi?n Flores Vadell www.speedbooksargentina.blogspot.com From fabianfloresvadell at ...626... Fri Sep 3 00:00:23 2010 From: fabianfloresvadell at ...626... (=?ISO-8859-1?Q?Fabi=E1n_Flores_Vadell?=) Date: Thu, 2 Sep 2010 19:00:23 -0300 Subject: [Gambas-user] Can you put a big box into a small one? Message-ID: I found that isn't possible set the width of a control to be higher than the width of its container. That's right? If so, this analogy of a physical constraint make not sense to me. Why the behaviour of a control follow this physical analogy? -- Fabi?n Flores Vadell www.speedbooksargentina.blogspot.com From rterry at ...1946... Fri Sep 3 00:01:31 2010 From: rterry at ...1946... (richard terry) Date: Fri, 3 Sep 2010 08:01:31 +1000 Subject: [Gambas-user] Inconsistent initialization in controls: seems a little bug In-Reply-To: References: <4C7F5E83.8000503@...1909...> Message-ID: <201009030801.31170.rterry@...1946...> On Friday 03 September 2010 07:43:34 Fabi?n Flores Vadell wrote: My 2c worth: Please don't introduce the nightmare of autoresize = true!!!!!!!!!! Regards Richard > 2010/9/2 Doriano Blengino : > > I agree - consistency; but the center question is the AutoResize > > property. If it is true by default, then the widget should show as soon > > as its text property is set to something "visible". If it is false, then > > the widget should not resize and, doing so, it should keep its default > > size. If its default size is zero, then the widget is invisible. The > > Autoresize seems to default to false, so gtk seems more logical. > > I think that have no sense that a graphic object is initialized to > (0,0,0,0), because make not sense that it become invisible in its > initial state. There's no logic in that. The purpose of a control is > showing something, so its initial state shouldn't be one that it > become invisible. > > I think about this goal can be achieved by making TRUE the default > value of AutoResize property in the control Label, that make sense > especially in this case because Labels always should show the value of > its Text property (show a half string o just a part make no sense. > Right?). So, default AutoResize = False go against the purpose of the > Label control. > > > Anyway, I believe that interactive editing of a form, and creatiaon of > > controls by code, are two different situations, with different > > requirements. > > Yes, they are two differents situations. But, what those diferent > requirements? > > > Consistency is desirable, if it does not clash with > > something else more important. > > I agree. But I don't see clash between consistency and anything else > in this case. > > Consistency matters because allow predict behaviors, but never can go > against the logical behavior of a object. So in this case consistency > and logical behavior of the control Label match, if the default value > to AutoResize is TRUE. > > > Regards. > From rterry at ...1946... Fri Sep 3 00:26:04 2010 From: rterry at ...1946... (richard terry) Date: Fri, 3 Sep 2010 08:26:04 +1000 Subject: [Gambas-user] Can you put a big box into a small one? In-Reply-To: References: Message-ID: <201009030826.05009.rterry@...1946...> On Friday 03 September 2010 08:00:23 Fabi?n Flores Vadell wrote: > I found that isn't possible set the width of a control to be higher > than the width of its container. That's right? If so, this analogy of > a physical constraint make not sense to me. Why the behaviour of a > control follow this physical analogy? > What programming env are you coming from out of interest, and what are you trying to design? Most situations you wouldn't want that conrols heigher than their physical container - harder for the user to use, however if you do need such a thing take a look at the scroll panel, and let us know what you are trying to acheive and most people on the list are more than willing to help, especially if you send in your project zipped for us to run. Don't know how long you've been programming in gambas, but in my experience, having been programming (non professionally I would hasten to add) since the early 1980's, and having programmed in Assembler, various windows gui languages, visual basic, python, wxPython, trips into Java, QT designer, I've found the gambas IDE and language to be one of the simplest and easiest to use fo all the IDE's I've ever encountered. My advice would be don't use GTK, use the QT side of gambas and let it the IDE do all the work for you. Steer clear of sticking things on panels, always use Vbox and Hbox or splits as containers. I've hundreds of forms and modules in my current project linking to a postgres backend with over 30 schemas and hundreds of tables and views and it all works like a charm. REgards RIcahrd From fabianfloresvadell at ...626... Fri Sep 3 00:50:13 2010 From: fabianfloresvadell at ...626... (=?ISO-8859-1?Q?Fabi=E1n_Flores_Vadell?=) Date: Thu, 2 Sep 2010 19:50:13 -0300 Subject: [Gambas-user] TextWidth Message-ID: When I try to adjust the width of a TextBox to its content, I use txtSomeThing.Width = txtSomeThing.TextWidth(txtSomeThing.Text). But doing that, the width of TextBox never be enought to show its content completely. I tried to find a correction factor but this is a fallible method. How I can adjust exactly the width of a TextBox to its content? -- Fabi?n Flores Vadell www.speedbooksargentina.blogspot.com From fabianfloresvadell at ...626... Fri Sep 3 01:20:46 2010 From: fabianfloresvadell at ...626... (=?ISO-8859-1?Q?Fabi=E1n_Flores_Vadell?=) Date: Thu, 2 Sep 2010 20:20:46 -0300 Subject: [Gambas-user] Can you put a big box into a small one? In-Reply-To: <201009030826.05009.rterry@...1946...> References: <201009030826.05009.rterry@...1946...> Message-ID: 2010/9/2 richard terry : Thanks Richard. I agree with your arguments about Gambas. Is a great tool. I'm writing examples and small proyects to use them in the docs I'm writing. Now I writing a graphic control, and I find that constraint. I hope that now, you can understand that I'm referring to that constraint make not sense for me when I'm programming. A control whose dimensions are greater than those of its container is only possible as a temporal (transitional) state. In most cases that state can't be showed to the user. -- Fabi?n Flores Vadell www.speedbooksargentina.blogspot.com From fabianfloresvadell at ...626... Fri Sep 3 01:22:44 2010 From: fabianfloresvadell at ...626... (=?ISO-8859-1?Q?Fabi=E1n_Flores_Vadell?=) Date: Thu, 2 Sep 2010 20:22:44 -0300 Subject: [Gambas-user] Inconsistent initialization in controls: seems a little bug In-Reply-To: <201009030801.31170.rterry@...1946...> References: <4C7F5E83.8000503@...1909...> <201009030801.31170.rterry@...1946...> Message-ID: 2010/9/2 richard terry : > Please don't introduce the nightmare of autoresize = true!!!!!!!!!! Arguments, please. -- Fabi?n Flores Vadell www.speedbooksargentina.blogspot.com From doriano.blengino at ...1909... Fri Sep 3 07:31:37 2010 From: doriano.blengino at ...1909... (Doriano Blengino) Date: Fri, 03 Sep 2010 07:31:37 +0200 Subject: [Gambas-user] Inconsistent initialization in controls: seems a little bug In-Reply-To: References: <201009011945.14184.gambas@...1...> <4C7F5E83.8000503@...1909...> Message-ID: <4C808839.4060204@...1909...> Fabi?n Flores Vadell ha scritto: > 2010/9/2 Doriano Blengino : > >> I agree - consistency; but the center question is the AutoResize >> property. If it is true by default, then the widget should show as soon >> as its text property is set to something "visible". If it is false, then >> the widget should not resize and, doing so, it should keep its default >> size. If its default size is zero, then the widget is invisible. The >> Autoresize seems to default to false, so gtk seems more logical. >> > > I think that have no sense that a graphic object is initialized to > (0,0,0,0), because make not sense that it become invisible in its > initial state. There's no logic in that. The purpose of a control is > showing something, so its initial state shouldn't be one that it > become invisible. > Perhaps you don't see the whole thing, which goes much deeper than the surface. Creating a label in Gambas+GTK means creating a gambas object which refers to a GTK object which refers to a GDK object which refers to a Xwindow object. Starting from XWindow and going up, an object is created "empty" (all dimensions set to zero, empty text, and so on), because it is logical not to set any dimension, at any level, because that dimension will be wrong - and "to zero" all the fields is the fastest thing to do. Setting any visual property of such object makes, by cascading over and over, a lot of things: don't forget repacking all containers in the hierarchy, marking dirty all those objects and repaint them. When in code you create a label, what should be its initial width? 100? 1000? A third of the screen width? Ten characters wide (using which font?)? It is true, a label is supposed to show something: but what? Only after you set the text property, a label comes in its true existence. Then, if Autoresize is already true, the label should resize itself. If Autoresize is false, nothing should happen. If you set Autoresize to true after having set the text property, may be that the label should resize, may be not (I would say yes, but it is debatable). May be that this does not work well in gambas (I made some test, and found something strange, but I don't remember well). > I think about this goal can be achieved by making TRUE the default > value of AutoResize property in the control Label, that make sense > especially in this case because Labels always should show the value of > its Text property (show a half string o just a part make no sense. > Right?). So, default AutoResize = False go against the purpose of the > Label control. > This could be a good idea, or not. I see that Richard does not agree, and probably I think the same. Sometimes it is handy, sometimes not. Anyway, if Autoresize was true by default, you can set it to false just after creation. > >> Anyway, I believe that interactive editing of a form, and creatiaon of >> controls by code, are two different situations, with different >> requirements. >> > > Yes, they are two differents situations. But, what those diferent requirements? > The difference is that when a widget is created by code, the runtime should make as little assumptions as possible, because the user program will set the properties just after the creation. When creating widgets in interactive mode, a few reasonable assuptions must be made, because otherwise the user would have difficulty to interact with the just created object. And those "reasonable" assumptions often are not enough. For example, all the widgets get a totally stupid name: Button1, Button2, TextBox25... when I see a program filled with "PUBLIC SUB Button8_Click()" my first thought is "this is a stupid programmer". Then I realize that I do the same, because I am too lazy to change those stupid names :-) > >> Consistency is desirable, if it does not clash with >> something else more important. >> > > I agree. But I don't see clash between consistency and anything else > in this case. > I see clashes, instead. Would you say, for example, that when creating a label by code, its text should be set to "Label 1" automatically? This would be consistent, because in interactive mode a label does so. Anyway, the clash is with efficiency of the program. When creating widgets by code, a runtime should make as little assumptions as possible. Perhaps, in this view, it is good that Autoresize defaults to false - more efficient. If you want it, you set it to true. > Consistency matters because allow predict behaviors, but never can go > against the logical behavior of a object. So in this case consistency > and logical behavior of the control Label match, if the default value > to AutoResize is TRUE. > > > Regards. > Regards, Doriano From doriano.blengino at ...1909... Fri Sep 3 07:39:25 2010 From: doriano.blengino at ...1909... (Doriano Blengino) Date: Fri, 03 Sep 2010 07:39:25 +0200 Subject: [Gambas-user] TextWidth In-Reply-To: References: Message-ID: <4C808A0D.9050103@...1909...> Fabi?n Flores Vadell ha scritto: > When I try to adjust the width of a TextBox to its content, I use > txtSomeThing.Width = txtSomeThing.TextWidth(txtSomeThing.Text). But > doing that, the width of TextBox never be enought to show its content > completely. > > I tried to find a correction factor but this is a fallible method. How > I can adjust exactly the width of a TextBox to its content? > The width of a widget refers to its outside width, including decorations. The interior width is a different thing, sometimes called ClientWidth; but I don't know if Gambas TextBoxes have a ClientWidth property. The size of the decorations should be always the same (in a given theme). I don't know how to calculate it but, supposed that this is possible and this is "8", something like txtSomeThing.Width = 8 + txtSomeThing.TextWidth(txtSomeThing.Text) could work, but I am not sure. Regards, Doriano From reynaldi.jansen at ...626... Fri Sep 3 08:49:03 2010 From: reynaldi.jansen at ...626... (Reynaldi Jansen) Date: Fri, 3 Sep 2010 13:49:03 +0700 Subject: [Gambas-user] Create Event Message-ID: Hello again. I have a form and textarea with tabstrip as parent... Then i create textarea1_cursor event in the first textarea... When user invoke to open new tab.count, it will create a new textarea... DIM hTextArea as TextArea TabStrip1.count += 1 hTextArea = NEW TextArea(TabStrip1) My question is, how to make thatnewtextarea_cursor event just like the first textarea1_cursor event? Thanks! From soleilpqd at ...626... Fri Sep 3 17:07:55 2010 From: soleilpqd at ...626... (=?UTF-8?B?UGjhuqFtIFF1YW5nIETGsMahbmc=?=) Date: Fri, 3 Sep 2010 22:07:55 +0700 Subject: [Gambas-user] Dialog multi-select Message-ID: Is there a way to select both files and folders in Dialog? I want to select multi items in a folder no distinguish that they're file or folder. From fabianfloresvadell at ...626... Fri Sep 3 20:00:46 2010 From: fabianfloresvadell at ...626... (=?ISO-8859-1?Q?Fabi=E1n_Flores_Vadell?=) Date: Fri, 3 Sep 2010 15:00:46 -0300 Subject: [Gambas-user] Inconsistent initialization in controls: seems a little bug In-Reply-To: <4C808839.4060204@...1909...> References: <201009011945.14184.gambas@...1...> <4C7F5E83.8000503@...1909...> <4C808839.4060204@...1909...> Message-ID: 2010/9/3 Doriano Blengino : > Perhaps you don't see the whole thing, which goes much deeper than the > surface. > Creating a label in Gambas+GTK means creating a gambas object which > refers to a GTK object which refers to a GDK object which refers to a > Xwindow object. > Starting from XWindow and going up, an object is created > "empty" (all dimensions set to zero, empty text, and so on), because it > is logical not to set any dimension, at any level, because that > dimension will be wrong - and "to zero" all the fields is the fastest > thing to do. I'm conscious about what happens behind the scene. Also, I agree with you that at X level is better not make assumptions. But like Gambas programmer, this doesn't matter to me. > Setting any visual property of such object makes, by > cascading over and over, a lot of things: don't forget repacking all > containers in the hierarchy, marking dirty all those objects and repaint > them. You are missing the point by changing the premise. That hipotetical situation of cascading settings between XWindows and GTK is not related with the topic. Anyway, if you are worried about how many graphics operations that are triggered by setting a control like Label think how many times this happens while a program is running. Hundreds? Thousands? Most of these things are do it as response to the user actions -move a window, resize it, minimize it, restore it, writing text, selecting text, etc - , and it's impredictable how many times they could ocurrs (but is sure that many many times). So, not worth taking into account. I think that Gambas programmers shouldn't be worried about that. > When in code you create a label, what should be its initial width? 100? > 1000? A third of the screen width? Ten characters wide (using which > font?)? It is true, a label is supposed to show something: but what? You forgot the start point, that is this: PUBLIC SUB _new() DIM lbl1 AS NEW Label(ME) lbl1.Text = "Hi people" END Are nothing to think if there's no text. > Only after you set the text property, a label comes in its true > existence. That's incorrect. If I do this: PUBLIC SUB _new() DIM lbl1 AS NEW Label(ME) PRINT lbl1 lbl1.Text = "Hi people" END I get this: (Label 0x9647e58) So, the object have identity just after its instantiation, like is logical. But I you are using an figurative mode of expression (if you meant not real existence, but meaningful existence) so I agree, that is the start point. > Then, if Autoresize is already true, the label should resize > itself. If Autoresize is false, nothing should happen. That is part on that we are discussing. >> I think about this goal can be achieved by making TRUE the default >> value of AutoResize property in the control Label, that make sense >> especially in this case because Labels always should show the value of >> its Text property (show a half string o just a part make no sense. >> Right?). So, default AutoResize = False go against the purpose of the >> Label control. >> > This could be a good idea, or not. I see that Richard does not agree, > and probably I think the same. Sometimes it is handy, sometimes not. No arguments here. > Anyway, if Autoresize was true by default, you can set it to false just > after creation. Why? You should argue that to labels set AutoResize=False as default, is more useful than the contrary, and I see many difficults to find solid arguments for that (I already argued about that, and I not want repeat my self over and over again). >> Yes, they are two differents situations. But, what those diferent requirements? >> > The difference is that when a widget is created by code, the runtime > should make as little assumptions as possible, because the user program > will set the properties just after the creation. > When creating widgets in interactive mode, a few reasonable assuptions > must be made, because otherwise the user would have difficulty to > interact with the just created object. And those "reasonable" > assumptions often are not enough. Yes, but anyway there's more similarities than differences. I not found reason to eliminate some of that similarities. > For example, all the widgets get a > totally stupid name: Button1, Button2, TextBox25... > when I see a program > filled with "PUBLIC SUB Button8_Click()" my first thought is "this is a > stupid programmer". Then I realize that I do the same, because I am too > lazy to change those stupid names :-) I agree, but you're losing the focus. >> I agree. But I don't see clash between consistency and anything else >> in this case. >> > I see clashes, instead. Would you say, for example, that when creating a > label by code, its text should be set to "Label 1" automatically? This > would be consistent, because in interactive mode a label does so. No, obviously I don't say that. You should remember the start point. > Anyway, the clash is with efficiency of the program. When creating > widgets by code, a runtime should make as little assumptions as > possible. Perhaps, in this view, it is good that Autoresize defaults to > false - more efficient. If you want it, you set it to true. I think that a Gambas programmer not should be worried about efficiency when the gain is merely marginal. Is much better to address it when the potential gain worthwhile. Not decrease the abstraction level of the language is several orders of magnitude more important. At this point a Gambas programmer should be concerned to follow GUI design principles, and to compliance the requirements. Compare this: 'gb.gtk PUBLIC SUB _new() DIM lbl1 AS NEW Label(ME) lbl1.Text = "Hi people" lbl1.Text = "Hi people" lbl1.W = lbl1.Font.Width(lbl1.Text) lbl1.H = lbl1.Font.Height(lbl1.Text) lbl1.X = 0 lbl1.Y = 0 END with this: PUBLIC SUB _new() DIM lbl1 AS NEW Label(ME) lbl1.Text = "Hi people" END By the way, in gb.gtk you can do this: lbl1.Text = "Hi people" lbl1.W = lbl1.Font.Width(lbl1.Text) lbl1.H = lbl1.Font.Height(lbl1.Text) lbl1.Show Oh my gosh! The X and Y properties were never set. ;-) Now seriously, and to finish with this topic, you shouldn't forget than in the most cases, labels will be placed in containers (like hbox) with other controls. So, in a high level of abstraction, its place is defined by the creation order, its width by the text and its height by the default font. As you can see, is possible make many assumptions in a inteligent manner. If some not use containers for the layout, so the problem -- Fabi?n Flores Vadell www.speedbooksargentina.blogspot.com From jussi.lahtinen at ...626... Fri Sep 3 21:18:22 2010 From: jussi.lahtinen at ...626... (Jussi Lahtinen) Date: Fri, 3 Sep 2010 22:18:22 +0300 Subject: [Gambas-user] Create Event In-Reply-To: References: Message-ID: "If you forget to specify the Name part, your object will never raise events!" http://gambasdoc.org/help/lang/new Jussi On Fri, Sep 3, 2010 at 09:49, Reynaldi Jansen wrote: > Hello again. > > I have a form and textarea with tabstrip as parent... > Then i create textarea1_cursor event in the first textarea... > > When user invoke to open new tab.count, it will create a new textarea... > > DIM hTextArea as TextArea > TabStrip1.count += 1 > hTextArea = NEW TextArea(TabStrip1) > > My question is, how to make thatnewtextarea_cursor event just like the first > textarea1_cursor event? > > Thanks! > ------------------------------------------------------------------------------ > This SF.net Dev2Dev email is sponsored by: > > Show off your parallel programming skills. > Enter the Intel(R) Threading Challenge 2010. > http://p.sf.net/sfu/intel-thread-sfd > _______________________________________________ > Gambas-user mailing list > Gambas-user at lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/gambas-user > From gambas at ...1... Sat Sep 4 02:22:16 2010 From: gambas at ...1... (=?utf-8?q?Beno=C3=AEt_Minisini?=) Date: Sat, 4 Sep 2010 02:22:16 +0200 Subject: [Gambas-user] Inconsistent initialization in controls: seems a little bug In-Reply-To: <201009011945.14184.gambas@...1...> References: <201009011945.14184.gambas@...1...> Message-ID: <201009040222.16822.gambas@...1...> > > I tested this only for control Label: > > > > When a control label is created in execution time using gb.qt, then > > > > control become visible just after assign a value at the Text property: > > PUBLIC SUB _New() > > > > DIM lbl1 AS NEW Label(ME) > > > > lbl1.Text = "Hi people" > > > > END > > > > But if you write the same code in a form using gb.gtk, the control > > Label keeps invisible until the properties X, Y, Width and Height gets > > values. > > I'm inclined to prefer the gb.gtk behaviour than the gb.qt one, aren't you? Some explanations, because it seems that things are not clear for you: There is no difference in what you can do with the GUI editor and what you can do directly by code. The Gambas compiler just transform the GUI description into normal Gambas code. So when you put a Label inside a control, it generates something like that: