Re: [Gambas-user] Showing the Form's Gui
Gracias Ricardo. Es lo que estaba buscando para un par de formularios rebeldes. Con algún retoque me vale. Un saludo. 2010/4/15 Fabien Bodard gambas...@gmail.com i don't know if richard want the user to be able to do anything on the showed form before the tatal loading ... the better way will be to do the loading in the timer by use the timer.trigger function the form .enabled will be set to false and the timer just set the form.enabled to true when the loading is ok when you set a contained enabled to false all the form content is set to false too. So the form is showed but not editable. 2010/4/13 Doriano Blengino doriano.bleng...@fastwebnet.it: Fabien Bodard ha scritto: 2010/4/13 Doriano Blengino doriano.bleng...@fastwebnet.it: Fabien Bodard ha scritto: just remember to put a flag to say when the data are loaded ! What would be the reason for this flag? if the form is showed and the data not accessible ? Really, there could be a problem if the user clicks a button 50 ms after the button (and the whole form) is visible. A remote possibility, and application-dependent. But I know users enough to imagine that someone could do it... :-) Reducing the interval of the one-shot timer can help, but does not solve (interval=0 could?). The better way is to disable actions the user could do with invalid data (application dependent: who says that the form is intended to receive clicks?), and perhaps add a nice label stating Loading data, please wait... and so on. Anyway, the flag is the worse solution. Supposing you use a flag, and the user clicks or types too fast, what would you do? A Message.Info(You clicked too fast. Go to have a coffee and come back later.)? :-) Better to disable some controls, so the user is informed before; in addition, controls are already global variables which carry informations with them. Well, this is my opinion - I hate to duplicate informations around, but someone else on this list, time ago, said never use the GUI to store information. The problem with global (or class) variables is that you can forget them more easily than some property of a visible control. Regards, Doriano -- Download Intel#174; Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev ___ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user -- Download Intel#174; Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev ___ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user -- Download Intel#174; Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev ___ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user
Re: [Gambas-user] static const?
Fabián Flores Vadell ha scritto: 2010/4/14 Doriano Blengino doriano.bleng...@fastwebnet.it: First example. I store some bookmarks... ... I could break out the loop using a logic variable, but this way I save a variable. Or I could test the variable in the loop construct, like this: I don't agree the criteria for saving one variable or one expresion if it is not justified. Well, perhaps my daily work with little CPUs (some have 32 bytes of ram!) drives me to professional bias, but why use a variable if can be avoided? There is more than one reason for this (reported without an order). One: variables have to be declared at the beginning of a block; when I write code, if I want to use a variable I must go back to the start of the code and add the declaration, leaving the old road of my mind. Then I must go back to the relevant part and concentrate again on the code. Two: saving a state to later break a loop is less straightforward than doing it in place. If the logic of an algorithm is concentrated in a single point, instead of being spread around, it is easier to revise - at least for me. Three: I think that fast algorithms are always better than slow ones. It is the duty of a good programmer to write good code: and good code is fast and easy to read. Perhaps, if I was a teacher, I would say different things. But teachers sometimes are a little distant from the reality; and scholars will face it later - when they will be programmers. Speed *is* important, the battle on computer hardware and software is all around performances. That said, using a variable is a cost (even more for interpreted languages like gambas). Well - we must understand each other. By no mean I want to say that using variables is awful - is a technique with pros and cons. Now, image an hypothetical case in that you have to do several conditional actions inside the loop. If you resolves it in that way, the code become hard to understand. Catch the joke: FOR tries = 1 TO 2' to search again from the top DO IF Upper(Left(ME.item.Text, i)) = searchstring THEN ' found item RETURN ENDIF IF ME.MoveBelow() THEN BREAK IF (YOU DONT LIKE) THEN RETURN IF (YOU WANT) THEN RETURN IF (NOT ME ..). THEN BREAK IF (YOU DONT...) THEN BREAK IF (YOU WRITE IN C) THEN RETURN ... LOOP ME.MoveFirst NEXT Ok, I know you wouldn't write something like that. Just I want to serve to show what I mean. Ah ah ah! You are wrong... this is my preferred style. I actually *write* things like that, especially when conditions are related. I mean - suppose you want to test the caption of a tabstrip (oh! what a coincidence...). You must read Tabstrip[i].Caption, but first you have to make sure that Tabstrip[i] really exists. So the test becomes: if (iTabStrip.count) and (tabstrip[i].caption blahblahblah) THEN blahblahblah This is a logical mislead, because it puts together two unrelated concepts: the test on the relevant thing (we look for caption), and a good precaution which has little to do with the algorithm. In fact, I would rewrite it as if itabstrip.count then if tabstrip[i].caption... There is no difference in the final (machine) code, but the second statement looks to me more explanatory. And, to be sincere, there is more. The ambiguity of the first statement is well stressed in other languages (sorry, they exist), where sometimes there is no warranty about the order of evaluation of expressions. For whatever reason, a compiler could evaluate tabstrip[i].caption *before* tabstrip.count. And, of course, the compiler is right - the AND operation is commutative (the two terms can be swapped), like addition and multiplication. Back to gambas - I don't know if the documentation says anything about short-circuit and things like that. May be we can assume it as a standard, that modern languages always do short-circuit, but the concept remains. This is why in many cases I could write, especially in a cycle: if i=tabstrip.count then break if tabstrip[i].caption ... then ... Here, the focus about the counter i, and the usage of .caption is even more separated - two statements instead of one - because they are at two different levels. This is only an example I stretched beyond the reality, but you got it. If you have to do tests (like unit tests) and you have routines with multiple exit points, maybe you will have some coverage problems. What do you think? I think that it is exactly the same thing. If you use a variable to break a loop, or return from a function, then that variable is an exit point. With an additional problem - that the variable can be changed later... a RETURN is always a RETURN instead. At this point, I would add that single return points are, for me, worse than multiple exit point. Excuse me again if I pull in other languages, but now they are
Re: [Gambas-user] Showing the Form's Gui
On Thursday 15 April 2010 08:07:56 Fabien Bodard wrote: The method suggested using the timer works for my use really well, and really simply. Users are much more tolerant if the gui is showing and processing going on in the background even if the busy cursor is showing briefly. This particular form in my program is a document inbox - where incoming messages - ranging from hl7 messages to scanned documents or internal messages have ended up in the users inbox. As it will usually only have a dozen or so entries a day, timing is not a ususally problem. Just for interest I loaded it with parsed messages, containing documents for 160 patients/640 odd documents, with 45,000 individual components to construct the documents final html (many were pathology reports hence granular in nature) and it took 1.6 seconds from postgres in yet to be indexed tables. Nothing needing to be done prior to loading. The delay in the gambas gui appearing is an interesting question, as in some other forms involving no such processing, loading is also slow - must investigate. Regards richard i don't know if richard want the user to be able to do anything on the showed form before the tatal loading ... the better way will be to do the loading in the timer by use the timer.trigger function the form .enabled will be set to false and the timer just set the form.enabled to true when the loading is ok when you set a contained enabled to false all the form content is set to false too. So the form is showed but not editable. 2010/4/13 Doriano Blengino doriano.bleng...@fastwebnet.it: Fabien Bodard ha scritto: 2010/4/13 Doriano Blengino doriano.bleng...@fastwebnet.it: Fabien Bodard ha scritto: just remember to put a flag to say when the data are loaded ! What would be the reason for this flag? if the form is showed and the data not accessible ? Really, there could be a problem if the user clicks a button 50 ms after the button (and the whole form) is visible. A remote possibility, and application-dependent. But I know users enough to imagine that someone could do it... :-) Reducing the interval of the one-shot timer can help, but does not solve (interval=0 could?). The better way is to disable actions the user could do with invalid data (application dependent: who says that the form is intended to receive clicks?), and perhaps add a nice label stating Loading data, please wait... and so on. Anyway, the flag is the worse solution. Supposing you use a flag, and the user clicks or types too fast, what would you do? A Message.Info(You clicked too fast. Go to have a coffee and come back later.)? :-) Better to disable some controls, so the user is informed before; in addition, controls are already global variables which carry informations with them. Well, this is my opinion - I hate to duplicate informations around, but someone else on this list, time ago, said never use the GUI to store information. The problem with global (or class) variables is that you can forget them more easily than some property of a visible control. Regards, Doriano - - Download Intel#174; Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev ___ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user --- --- Download Intel#174; Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev ___ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user -- Download Intel#174; Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev ___ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user
Re: [Gambas-user] static const?
Back to gambas - I don't know if the documentation says anything about short-circuit and things like that. May be we can assume it as a standard, that modern languages always do short-circuit, but the concept remains. Gambas doesn't have short-circuits, you have to write like this: IF a=1 AND IF b=2 THEN Jussi -- Download Intel#174; Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev ___ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user
Re: [Gambas-user] static const?
Jussi Lahtinen ha scritto: Back to gambas - I don't know if the documentation says anything about short-circuit and things like that. May be we can assume it as a standard, that modern languages always do short-circuit, but the concept remains. Gambas doesn't have short-circuits, you have to write like this: IF a=1 AND IF b=2 THEN Ah! Thanks. So, a statement like this: if itabstrip1.count and tabstrip1[i].caption= can fail, if I understand well. Perhaps I must check a few lines of code... Regards, Doriano -- Download Intel#174; Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev ___ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user
Re: [Gambas-user] static const?
Am Donnerstag, den 15.04.2010, 19:28 +0200 schrieb Doriano Blengino: Jussi Lahtinen ha scritto: Back to gambas - I don't know if the documentation says anything about short-circuit and things like that. May be we can assume it as a standard, that modern languages always do short-circuit, but the concept remains. Gambas doesn't have short-circuits, you have to write like this: IF a=1 AND IF b=2 THEN Ah! Thanks. So, a statement like this: if itabstrip1.count and tabstrip1[i].caption= can fail, if I understand well. Perhaps I must check a few lines of code... Regards, Doriano Salut, I'v never done it like that (IF a=1 AND IF b=2 THEN), are you sure ? -- Amicalement Charlie -- Download Intel#174; Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev ___ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user
Re: [Gambas-user] static const?
Yes, you can test it. This should generate error: If 1 = 2 And 1 / 0 Then Print test This should not.: If 1 = 2 And If 1 / 0 Then Print test Jussi On Thu, Apr 15, 2010 at 20:56, Charlie Reinl karl.re...@fen-net.de wrote: Am Donnerstag, den 15.04.2010, 19:28 +0200 schrieb Doriano Blengino: Jussi Lahtinen ha scritto: Back to gambas - I don't know if the documentation says anything about short-circuit and things like that. May be we can assume it as a standard, that modern languages always do short-circuit, but the concept remains. Gambas doesn't have short-circuits, you have to write like this: IF a=1 AND IF b=2 THEN Ah! Thanks. So, a statement like this: if itabstrip1.count and tabstrip1[i].caption= can fail, if I understand well. Perhaps I must check a few lines of code... Regards, Doriano Salut, I'v never done it like that (IF a=1 AND IF b=2 THEN), are you sure ? -- Amicalement Charlie -- Download Intel#174; Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev ___ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user -- Download Intel#174; Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev ___ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user
Re: [Gambas-user] static const?
Charlie Reinl wrote: Am Donnerstag, den 15.04.2010, 19:28 +0200 schrieb Doriano Blengino: Jussi Lahtinen ha scritto: Back to gambas - I don't know if the documentation says anything about short-circuit and things like that. May be we can assume it as a standard, that modern languages always do short-circuit, but the concept remains. Gambas doesn't have short-circuits, you have to write like this: IF a=1 AND IF b=2 THEN Ah! Thanks. So, a statement like this: if itabstrip1.count and tabstrip1[i].caption= can fail, if I understand well. Perhaps I must check a few lines of code... Regards, Doriano Salut, I'v never done it like that (IF a=1 AND IF b=2 THEN), are you sure ? Yes, It is clearly there in the manual. *IF* _Expression_ [ { *AND IF* | *OR IF* } _Expression_ ... ] [ *THEN* ] ... [ *ELSE IF* _Expression_ [ { *AND IF* | *OR IF* } _Expression_ ... ] [ *THEN* ] ... ] [ *ELSE* ... ] *ENDIF* -- Download Intel#174; Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev ___ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user
Re: [Gambas-user] static const?
I don't agree the criteria for saving one variable or one expresion if it is not justified. Well, perhaps my daily work with little CPUs (some have 32 bytes of ram!) drives me to professional bias, but why use a variable if can be avoided? There is more than one reason for this (reported without an order). One: variables have to be declared at the beginning of a block; when I write code, if I want to use a variable I must go back to the start of the code and add the declaration, leaving the old road of my mind. Then I must go back to the relevant part and concentrate again on the code. I don't see the problem here. When you think about create a variable (or any other memory structure), you never let to think about your algorithm. In fact, if the language require previous variable declaration is a good thing because forces to think about on resources you will use and how you will do that. I think that the choices about memory structures is one of the critical parts when you write an algorithm. So, when you think about variables far away of divert attention, actually you are deepening your understanding about the problem and your algorithmic solution. Two: saving a state to later break a loop is less straightforward than doing it in place. If the logic of an algorithm is concentrated in a single point, instead of being spread around, it is easier to revise - at least for me. Three: I think that fast algorithms are always better than slow ones. I think that if the speed is a requeriment, that's right. But if not, just is right if is to easy to do. So, not always a faster algorithm is better. Let me quote to Donald Knuth when he said premature optimization is the root of all evil (or at least most of it) in programming. It is the duty of a good programmer to write good code: and good code is fast and easy to read. I believe that a good code is one that is simple, and to achieve this goal at least must (sure I forget something): - Uses the correct structures of memory and control - Have high cohesion and low coupling - Be correctly modularized - Uses good names - Be written in order that it is easy to understand it Perhaps, if I was a teacher, I would say different things. But teachers sometimes are a little distant from the reality; and scholars will face it later - when they will be programmers. The industry insists in that the most important things are compliance of requirements and easy maintenance. That said, using a variable is a cost (even more for interpreted languages like gambas). Well - we must understand each other. By no mean I want to say that using variables is awful - is a technique with pros and cons. Easy, I understand you. if (iTabStrip.count) and (tabstrip[i].caption blahblahblah) THEN blahblahblah This is a logical mislead, because it puts together two unrelated concepts: the test on the relevant thing (we look for caption), and a good precaution which has little to do with the algorithm. In fact, I would rewrite it as if itabstrip.count then if tabstrip[i].caption... There is no difference in the final (machine) code, but the second statement looks to me more explanatory. I agree. And, to be sincere, there is more. The ambiguity of the first statement is well stressed in other languages (sorry, they exist), where sometimes there is no warranty about the order of evaluation of expressions. For whatever reason, a compiler could evaluate tabstrip[i].caption *before* tabstrip.count. And, of course, the compiler is right - the AND operation is commutative (the two terms can be swapped), like addition and multiplication. Back to gambas - I don't know if the documentation says anything about short-circuit and things like that. May be we can assume it as a standard, that modern languages always do short-circuit, but the concept remains. I agree. function movefile(src, dst as string) as boolean result = false if not exists(src) then return if not open_and_read(src) then return close(src) if not open_and_write(dst) then return close(dst) result = true end Now comes personal taste. The second routine, for you, is a joke. Oh, no. The joke was: IF (YouWriteInC) THEN RETURN. Maybe, we not share the same humor sense. For me, it looks simpler, shorter, and faster. The only problem I see are those repeated not and return. They are ugly to see, but very clear in saying if this operation fails, then stop. The code coverage should be simpler to do, but I am not really sure. When I have to write many logical tests, I separates them in a new function. That allow me keep the code short and self explanatory. I do this in a extremist way especially when I want to anybody can understand my code. I know this is even more expensive than using a variable. I don't care, I never seen a penalization over performance for that, and if I have to do some optimization, I would do later. I think that the
Re: [Gambas-user] static const?
Am Donnerstag, den 15.04.2010, 21:07 +0300 schrieb Jussi Lahtinen: Yes, you can test it. This should generate error: If 1 = 2 And 1 / 0 Then Print test This should not.: If 1 = 2 And If 1 / 0 Then Print test Jussi On Thu, Apr 15, 2010 at 20:56, Charlie Reinl karl.re...@fen-net.de wrote: Am Donnerstag, den 15.04.2010, 19:28 +0200 schrieb Doriano Blengino: Jussi Lahtinen ha scritto: Back to gambas - I don't know if the documentation says anything about short-circuit and things like that. May be we can assume it as a standard, that modern languages always do short-circuit, but the concept remains. Gambas doesn't have short-circuits, you have to write like this: IF a=1 AND IF b=2 THEN Ah! Thanks. So, a statement like this: if itabstrip1.count and tabstrip1[i].caption= can fail, if I understand well. Perhaps I must check a few lines of code... Regards, Doriano Salut, I'v never done it like that (IF a=1 AND IF b=2 THEN), are you sure ? -- Amicalement Charlie Salut, yes you are right for that example (my teacher said never try to divide something by 0). And I do not understand why/what/where that condition is/could be good for ... 1/0 !? but If 1 = 1 And 1 2 Then Print test and If 1 = 1 And If 1 2 Then Print test works the same way. -- Amicalement Charlie -- Download Intel#174; Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev ___ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user