Creating a class requirig mandatory parameters
Posted
#1
(In Topic #1532)
Regular

I'm trying to create a new class something that requires 3 parameters i.e.
in a separate class file in the project I've defined the class as follows…
but get the error…
Missing AS (OPC.class:3)
What am I doing wrong?
Posted
Administrator

You are trying to create a new method but a class is required :?DIYTinkerer said
but get the error…
Missing AS (OPC.class:3)
What am I doing wrong?
If i understand what you try to achieve:
You need to make a class named OPC. Then in OPC:
I have made a little example and added some properties, a method and a function, so you can see data was transferred and stuff gets done. Just run in IDE and look in the console what happens, then study and ask questions if needed, right here. It's made in 3.19.6, if you have a lower version just do a compile all if IDE complains.
gbWilly
- Gambas Dutch translator
- Gambas wiki content contributor
- Gambas debian/ubuntu package recipe contributor
- GambOS, a distro for learning Gambas and more…
- Gambas3 Debian/Ubuntu repositories
… there is always a Catch if things go wrong!
- Gambas Dutch translator
- Gambas wiki content contributor
- Gambas debian/ubuntu package recipe contributor
- GambOS, a distro for learning Gambas and more…
- Gambas3 Debian/Ubuntu repositories
… there is always a Catch if things go wrong!
Posted
Guru

A class is defined by a separate file with a name, eg. OPC.class
And as gbWilly says the special method _new() /lang/special/new - Gambas Documentation is used.
the _new method is called for a "creatable" class when you use the New keyword to create an object like this…
Dim hOPC As OPC = New OPC(CenterX, CenterY, Radius)
If you want to use OPC.class directly without creating an object you should look into Static /lang/static - Gambas Documentation
Posted
Regular

As others have raised, a class is no something that you can "create" on the fly (well it can be, but not until postgrad work). A class for want of a better word is a "specification" of a set of organisms whose existence can come and go as required by the universe. Each star is an "instance" of the class "star" but it is not "the" star. A dog is not "the" animal, but it is "a" animal as in an instance of the class animal with 4 legs that says "woof".
I attach the world famous but rotten Animals project for your enjoyment.
Posted
Regular

Posted
Regular

Thanks - this is also very helpful - I have been thinking of classes slightly wrong -thatbruce said
Now let us discuss what a "class" is, what it's attributes, methods¸ signals (events) are and what it is not.
As others have raised, a class is no something that you can "create" on the fly (well it can be, but not until postgrad work). A class for want of a better word is a "specification" of a set of organisms whose existence can come and go as required by the universe. Each star is an "instance" of the class "star" but it is not "the" star. A dog is not "the" animal, but it is "a" animal as in an instance of the class animal with 4 legs that says "woof".
I attach the world famous but rotten Animals project for your enjoyment.
animals-0.0.1.tar.gz
1 guest and 0 members have just viewed this.

