2011/5/20 Rob <sourceforge-raind...@kudla.org>: > On Friday 20 May 2011 06:08, j h wrote: >> For example a simple program >> has a window with a Valuebox, a button and a slider. How do i program >> it so when i press the button the value of the slider is displayed in >> the valuebox? If anyone can carefull explain how, not just write the >> code, it would really help me get going! Thanks > > Fabien already posted the code, but as far as "how" goes: > > How you actually do it in the IDE: > > Double click the button, it'll create a Sub (subroutine) for you, and in > that subroutine you write the one line of code that takes the value of the > slider and puts it in the valuebox. Press F5 and it'll compile and run > your program. > > How it works: > > The button, slider and valuebox are all "objects". This is how most > languages work now: instead of just variables, the things you see on the > screen are self-contained objects with their own code ("methods", though > few languages actually use that term in the code) and variables of their > own (most of which are called "properties"). > > When the user clicks the button, an "event" is generated. There was > nothing like this in Sinclair BASIC and Amiga BASIC had only a little of > that; the closest thing in 8- and 16-bit computing was the "interrupts" > used in assembly language to jump to a particular section of code when the > user pressed a key. The OS gets the mouse button click, the windowing > system determines the mouse is over your button, and sends the event to > Gambas. The Gambas interpreter checks to see if you have code to run when > that event happens, and runs it for you, so all you have to think about is > what happens next. > > In a 1980s BASIC program, you would have had a loop waiting for input to > happen. In Gambas, this is done by the interpreter (and much more > efficiently), not your own code. Event handlers you write, like > Button1_Click in Fabien's example, replace the big lists of if/thens we > used to write back then to figure out what the user did and take action > based on it. > > Coming from totally procedural code on a single-tasking system like > Sinclair BASIC, object-oriented programming with event handling can take a > while to grasp. VB, Javascript/AJAX, and most graphical programming in > Java, C/C++, Python, etc. all work the same way nowadays, so once you > figure it out in Gambas you'll probably be able to do it in any modern > language you learn. > > Rob > > ------------------------------------------------------------------------------ > What Every C/C++ and Fortran developer Should Know! > Read this article and learn how Intel has extended the reach of its > next-generation tools to help Windows* and Linux* C/C++ and Fortran > developers boost performance applications - including clusters. > http://p.sf.net/sfu/intel-dev2devmay > _______________________________________________ > Gambas-user mailing list > Gambas-user@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/gambas-user >
sorry i did it between two doors ='( -- Fabien Bodard ------------------------------------------------------------------------------ What Every C/C++ and Fortran developer Should Know! Read this article and learn how Intel has extended the reach of its next-generation tools to help Windows* and Linux* C/C++ and Fortran developers boost performance applications - including clusters. http://p.sf.net/sfu/intel-dev2devmay _______________________________________________ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user