Posts: 394
Threads: 16
Joined: Jun 2003
I've never used classes to define my variables. Excluding arrays, I just flat out use the variable. So why should I use the:
Code:
TYPE blah
blah.contents AS type
END TYPE
declarations? Does it speed up the program? Add a new feature?
ammit potato!
Posts: 2,020
Threads: 24
Joined: Jun 2002
It actually works like this:
type blah
attribute1 as integer
attribute2 as integer
attribute3 as integer
end type
such that you could do something like this
dim blah(10) as blah
blah(1).attribute1 = 10
blah(1).attribute2 = 5
type structures are very useful for organizational reasons, and having the benefit of making things like records or multiple types in a single array. They're used in other languages like C too.
i]"I know what you're thinking. Did he fire six shots or only five? Well, to tell you the truth, in all this excitement, I've kinda lost track myself. But being as this is a .44 Magnum ... you've got to ask yourself one question: 'Do I feel lucky?' Well, do ya punk?"[/i] - Dirty Harry
Posts: 1,813
Threads: 284
Joined: Mar 2003
If I am to understand correctly jofers, types in QB are the equivalent of classes in C++?
earn.
Posts: 22
Threads: 0
Joined: Jun 2003
Quote:If I am to understand correctly jofers, types in QB are the equivalent of classes in C++?
More like... wannabe structs. Minus some stuff. But yeah.
-[Unknown]
Posts: 3,368
Threads: 195
Joined: Jan 2003
types are good for making compact dim code, but the type format is for some unknown reason different than other formats. (yes, qb *can* recognize the difference even if they have the same format, and NO, qb forces you to add to a type say "mouse" if you already defined it, can't just say "DIM shared mouse.newvar as integer")
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."
Visit www.neobasic.net to see rubbish in all its finest.
Posts: 720
Threads: 46
Joined: Oct 2001
Quote:"]More like... wannabe structs. Minus some stuff. But yeah.
lol. Well put. A class is far more powerful than a mere TYPE.
Posts: 1,956
Threads: 65
Joined: Jun 2003
Potato: I agree with you, I have the same feeling. I can't really find the advantage of TYPE's. I have written hundreds of production programs in QuickBasic, and the only time I used TYPE's was to conform to some function that I was using from a library or incorporating into my program.
I'm open to being enlightened as to its advantages.
*****
Posts: 704
Threads: 0
Joined: Dec 2002
in SUB/CALL statements from being unwieldy.
ravelling Curmudgeon
(geocities sites require copying and pasting URLs.)
I liked spam better when it was something that came in a can.
Windows should be defenestrated.
Posts: 780
Threads: 49
Joined: Dec 2001
Just down to organisation.
I honestly don't know the coding significance they may have, but as far as I have used them, it's been pretty much style. I DO use types, simply because I find it much easier to work with. Let's take the classic example of the RPG. Lovely World/Player/NPC type. Simplifies everything and makes stuff easy to understand and organise.
If you don't want to use it, I don't see why you should apart from the aforementioned "conforming".
Posts: 720
Threads: 46
Joined: Oct 2001
The data structure support in QB is so poor that there really isn't a whole lot of point, but it's a good practise to get into for other languages. Once you move on, you will meet nested structures and tihngs called pointers and then you'll want user defined types for sure...