what about the classes?
Posted
#1
(In Topic #570)
Trainee
Sorry, I'm beginner (not in time, but in apps I already composed)
And I'm not English, so please bare that in mind ….
Thanks
Posted
Regular

vito49 said
Hello guys, I wonder why there are "classes" to use … but I have no clue why they are used and how to use them…
In Object Orientated Programming, a class is a kind of template that you can use to create a new "instance" of an "object".
Sounds scary?
When you simply draw a control Button on a form, you use the Button class code to create a new instance (new version/new Button object) of the software that manages a button. This new button object allows you to customise your button with a new name, a new text caption, new size, new colour…and so on.
If we did not have a Button class we all would have to write our own code to draw our own buttons and control how they work …we would all be re-inventing the wheel!
I'll try to come up with a simple class example with its own Methods (Functions) and Properties.
Posted
Regular

Start a new GUI Gambas project, but don't draw any components on the Form, just add this code to FMain.class:-
Code (gambas)
What this code is doing is creating a new button from the existing code class called Button. We call this creating a new instance of the class Button by declaring myButton as a Button.
We can then use the Button class Properties to set size, colour, text & so on.
Is this helping?
Posted
Guru

The Class may seem a little complicated, but I hope you can see how this small amount of code can do so much.
Code (gambas)
<IMG src="https://www.cogier.com/gambas/ClassExample.png">
</IMG>
Posted
Enthusiast

Posted
Guru

Really!!PJBlack said
the carpenters ??? really ???
Posted
Regular

cogier said
Really!!PJBlack said
the carpenters ??? really ???
![]()
…he's only just begun
Posted
Enthusiast

back to topic:
charlie … i'm an f***ing old procedural programmer with big fears of OOP for a long time and it tokks me a lot of hard work to get into it … but while understanding how it works or maybe how i should work i will say "oh wow … how could i program without that" … taking your second example a newbie would likely say "oh hell …" but yes it shows what a class can be
vito:
fight your way trough … programing is fun and you will find solutions for problems that you won't have without programing
you may like to have a look here:
https://gambas-buch.de/dwen/doku.php?id=start
for years now hans lehmann wrote on that and for a starter it is very helpfully, most of it should be in english but also avail in german … i you have any questions the carpenters and the rest here will try to help you
Posted
Guru

…he's only just begun
I'm beginning to feel unwell
Posted
Regular

Posted
Guru

cogier said
…he's only just begun
I'm beginning to feel unwellops:
Don't feel bad Charlie.
Just sing , sing a song
because we long to be ,,,
close to you….
aaaaaaah aaaaaaah aaah
close to you
1 guest and 0 members have just viewed this.


