Posts: 144
Threads: 8
Joined: Feb 2004
Hey, I am working on a program in Direct X (C++, not C#), and want to practice working on physics using particles in QBasic. I haven't programmed in QBasic in a while, and I can't seem to make functions return my user-defined types. This must be possible (I can't imagine MS would want to make you pass by reference instead).
Please tell me this is possible, I don't want to have to go ahead and learn C# for quicky practice things like this.
Posts: 1,272
Threads: 36
Joined: Feb 2003
QB doesn't let you return user defined types, but you can use a parameter instead.
Posts: 144
Threads: 8
Joined: Feb 2004
That is what I was afraid of...
Anyone know why they decided to force you to pass by reference?
Posts: 6,419
Threads: 74
Joined: Mar 2002
They didn't. You can use BYVAL to pass by value
Posts: 144
Threads: 8
Joined: Feb 2004
Quote:They didn't. You can use BYVAL to pass by value 
Sorry, I meant "Why did they force you to pass by value instead of returning a user-defined type?"
Every other language I know of allows you to return any type, not just the built in.
Posts: 3,279
Threads: 170
Joined: Nov 2003
Every other modern language allows you to do this. However, keep in mind that QB is exceptionally old.
I'd knock on wood, but my desk is particle board.
Posts: 144
Threads: 8
Joined: Feb 2004
Quote:Every other modern language allows you to do this. However, keep in mind that QB is exceptionally old.
Well, C and Scheme are older than QB, as well as I beleive C++ and Lisp.
Posts: 3,279
Threads: 170
Joined: Nov 2003
BASIC is older than C. And virtually all modern BASICs allow your own return types for your own functions. QB 4.5 simply doesn't. I am not sure, but I think 7.1 actually does. Anyone care to confirm this? I don't have a copy handy at the moment.

And don't forget that QB is a compiler that compiles a form of BASIC. C has many compilers but there is no compiler called C.
I'd knock on wood, but my desk is particle board.
Posts: 144
Threads: 8
Joined: Feb 2004
BASIC is older than C, you are right, but it came out about 20 years befroe QBasic. I was just wondering if anyone knew why MS didn't see the need for functions to return user-defined types,.
Posts: 3,279
Threads: 170
Joined: Nov 2003
No idea.

It'd be quite useful though...

Oh well...VB does it quite well
I'd knock on wood, but my desk is particle board.