Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Suggested improvement for DBPro

Author
Message
Gamer
23
Years of Service
User Offline
Joined: 29th Apr 2003
Location:
Posted: 15th Jun 2003 02:55
As great a game programming language DBPro is, I hope its future version will support the use of subroutines so that we can pass parameters around. Right now, everything is global, and the more global variables there are, the more memory it's required for the program to run. But more importantly, the more global variables there are, the harder it is to debug.
aprilfan
23
Years of Service
User Offline
Joined: 3rd Oct 2002
Location: Hell
Posted: 15th Jun 2003 03:00
Back in the QB days we had subroutines and functions but now we just have functions I think in DB though variables in functions are specifically for the functions. Not global. Am I right?

The Great Schism.- The Earths reaction to Heavons invasion.
andrew11
23
Years of Service
User Offline
Joined: 23rd Feb 2003
Location: United States
Posted: 15th Jun 2003 06:00 Edited at: 15th Jun 2003 06:02
Wha????

First, all variables aren't global. In functions they aren't. You can pass variables around in functions. And if you are that worried about memory leaks with variables, I assume you wont ever use arrays, objects or images. It does make it harder to debug, but you can reuse variables.
Second, DBPro and DBC support functions and subroutines; just not on seperate pages, as in QBASIC. Variables in functions are seperate, and to use them in the main program, use



"All programmers are playwrites and all computers are lousy actors" -Anon
Click Here!!!
Gamer
23
Years of Service
User Offline
Joined: 29th Apr 2003
Location:
Posted: 15th Jun 2003 09:08
First, I did not say I'm worried about memory leaks. So, read my post carefully! Second, of course all variables are global. Sure you can pass variables around in functions, but a function can only return one value. And all the parameters that you pass into a function are being passed by value, not by reference. Any variables that are not being passed into a function but used inside a function are local variables, but those variables do not retain their values once we exit out of the function. And how does DBPro support subroutines? Can you call a subroutine where you can pass in parameters? I don't see it being documented anywhere in the manual. And don't try to tell me GOSUB is calling a subroutine because it isn't. It's merely branching to a label.

Rob K
Retired Moderator
23
Years of Service
User Offline
Joined: 10th Sep 2002
Location: Surrey, United Kingdom
Posted: 15th Jun 2003 12:30
Surely a function without a return value is by definition, a sub-routine?

Certainly in Pascal and VB, the values are not retained once you exit the sub routine.

The best answer would be to mimick the functionality of functions, ie, stick the parameters on the stack, GOSUB, clear the stack.

Do you want Windows menus in your DBP apps? - Get my plugin: http://snow.prohosting.com/~clone99/downloads/tpc_menus_103.zip
ICERGB
23
Years of Service
User Offline
Joined: 8th Nov 2002
Location: Canada
Posted: 15th Jun 2003 12:58
You should see the amount of variables I have used in a DBProgram
without undiming... It is crazy...

Maybe a little more "show" and a little less "should be".
andrew11
23
Years of Service
User Offline
Joined: 23rd Feb 2003
Location: United States
Posted: 15th Jun 2003 21:21 Edited at: 15th Jun 2003 21:22
If you didn't mean memory leaks, then what did you mean? The amount of memory used for variables is very little. And DBPro has subroutines, just not on seperate pages like QB. Have you ever opened a QB .bas file in notepad? If anything, DBPro is easier to use subroutines.

"All programmers are playwrites and all computers are lousy actors" -Anon
Click Here!!!
Gamer
23
Years of Service
User Offline
Joined: 29th Apr 2003
Location:
Posted: 15th Jun 2003 23:34
What I am merely getting at is that we are not able to pass in parameters (by reference) into a 'subroutine', period. More often than not, we need to update the values of more than one variable inside a subroutine. In such case, we are doomed. We can't use a function because it can only return one value. So, what do we have to do is to make those other variables global. See what I'm getting at?

Shadow Robert
23
Years of Service
User Offline
Joined: 22nd Sep 2002
Location: Hertfordshire, England
Posted: 16th Jun 2003 07:42
didn't qBasic have Proceedures rather than SubRoutines or Functions, which are kinda different to both.

Quote: "And how does DBPro support subroutines? Can you call a subroutine where you can pass in parameters? I don't see it being documented anywhere in the manual. And don't try to tell me GOSUB is calling a subroutine because it isn't. It's merely branching to a label."

Quote: "Surely a function without a return value is by definition, a sub-routine?"


... erm guys there is a clue within the name ...
SUB (Background/Underneath)
ROUTINE (Section of Repeated Code)

a SubRoutine & Functions are different kettles of fish entirely, and they're used identically as to how they are within VisualC++

a SubRoutine is a section of code which is kept seperate from the main section of code and can be called many times within...



although yes this could be encapsulated within a function, all that the Subroutine actually is ... is a section of code which is part of the main Routine technically - it is just jumped to whenever you call it, the code will immediate jump back afterwards.
It is still part of the main code though and cannot be transfered or altered, kinda like a static function if you will. But it does have some inherint advantages over an actual function.

The main being that they don't actually take up any memory when they're being run, a function will be shifted into the memory using its own section of memory for the values it uses during its term - a subroutine doesn't require any memory to process as it only uses already declared values which are currently present within the memory ... this means you can use them inside/outside of funciton encapsulation.

MyValue as dword // this can be used within the main routine and sub routines
Global MyValue as dword // this can also be used in function
Local MyValue as dword // this is destoryed whenever a new instance is created, which means if it is create outside of a loop it is only valid uptil that loop. if it is created inside a subroutine it is valid until the loop loops. if it is created inside a function it retains full encapsulation.

anything created inside a function is automatically encapsulated unless you tell it otherwise. (this didn't used to be completely true, but was fixxed in the latest patches)

#constant's are just inlines - swap one thing for another, e.g.

#constant CUBE make object cube (m_pObject=m_pObject+1)
CUBE,10.0 `//will create a new cube size 10.0

you can actually get extremely complex with them, especially if you interlink them - but i'd be careful as it only really likes 1 level of inline code.

Within the Epic battle of the fates the Shadow and the Angel will meet. With it will harbinger the very fight of good vs evil!
SS1k
23
Years of Service
User Offline
Joined: 19th Nov 2002
Location: United States
Posted: 16th Jun 2003 08:05
If there is something I want in the upgrade, it is the use of real-time reflections and real-time shadows.

.:SIDEP0CKET:.
:..>Mind is Thought
:..>Play is Fun
Puffy
23
Years of Service
User Offline
Joined: 4th Sep 2002
Location: United States
Posted: 16th Jun 2003 10:19
=\ You guys must remember no matter how powerful DB is its still just a BASIC... I don't think many people on here would even use the references... I love em... but Its not really required for the language to work... and including them might make things over complicated... O_O Plus if we give em references we gotta give em pointers and you can really mess up your comp if you make a mistake with those (memory leaks...) =P At least thats why I wouldn't include em... Lee might have a different idea...

EVERYONE LOVES THE PUFF!... =\
Shadow Robert
23
Years of Service
User Offline
Joined: 22nd Sep 2002
Location: Hertfordshire, England
Posted: 17th Jun 2003 04:33
Puffy have you even used DBP yet?
we have a fully working pointer & memory system which actually begs the question to why we don't yet have arrayed UDT's and reference passing of data.

ho hum eh lol

Within the Epic battle of the fates the Shadow and the Angel will meet. With it will harbinger the very fight of good vs evil!
Username Goes Here
User Deleted
Posted: 17th Jun 2003 18:40 Edited at: 17th Jun 2003 18:42
A manual! Most questions could be answered if the manual wasn't just a collection off short descriptions that you could imagine yourself by the commands name. What is the purpose of not documenting allmost every flag???? Also, why aren't the commands sorted in their categories? An Index, grouped by the first character isn't very helpful when the commands inside the group aren't sorted, or? To me DB Pro is mostly try and error. So you find out what is declared at start and what not. You guys could make it for DB beginners much much easier! Without much work.

Also, I would like to see the ability to render to the backbuffer without flip it to the front like the SYNC command does.
Also I would like to get the coords of a vertice or a face that I
clicked with the mouse on it.

Cu
Michael

andrew11
23
Years of Service
User Offline
Joined: 23rd Feb 2003
Location: United States
Posted: 17th Jun 2003 19:13
I don't think that there is a problem with the manual. The problem is people who are too busy complaining to actually try and learn.

"All programmers are playwrites and all computers are lousy actors" -Anon
Click Here!!!
Dreamora
23
Years of Service
User Offline
Joined: 20th Sep 2002
Location: Switzerland
Posted: 17th Jun 2003 19:34
Quote: "we have a fully working pointer & memory system which actually begs the question to why we don't yet have arrayed UDT's and reference passing of data."


good joke Raven
where are pointer? I can't remember there where any pointer so I could build my own ADT Structures like fibonacci heap or avl trees, so where the hell do you see pointer?

I'm still waiting for real pointer to work on the level of a real programming language not just some wrapper language.

the only real pointer that DBP has are the pointer to backbuffer etc. but no other real pointer system.

Puffy
23
Years of Service
User Offline
Joined: 4th Sep 2002
Location: United States
Posted: 17th Jun 2003 19:42
=\ I could try and make a dll that gives you guys a pointer...

EVERYONE LOVES THE PUFF!... =\
andrew11
23
Years of Service
User Offline
Joined: 23rd Feb 2003
Location: United States
Posted: 17th Jun 2003 21:22
I don't know much about pointers, but all I had to do is search the help file and found these:

GET PIXELS POINTER
GET MEMBLOCK PTR
GET BACKBUFFER PTR

"All programmers are playwrites and all computers are lousy actors" -Anon
Click Here!!!
IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 17th Jun 2003 21:41
... and using GET BACKBUFFER PTR() to poke to the display



You don't currently have 'pointers to structures' in the classic C style, but for storage purposes, you can certainly do all the classic data structures like heaps and trees using arrays.
Shadow Robert
23
Years of Service
User Offline
Joined: 22nd Sep 2002
Location: Hertfordshire, England
Posted: 17th Jun 2003 21:58


how you use the pointer system is upto you, and it is ALOT more indepth than perhaps you realise... i could do something one hell of alot more complex than that but hopefully it'll show the fairly novice user how they maybe a little useful

I pride myself that i don't kill...
well not without a good reason
Username Goes Here
User Deleted
Posted: 18th Jun 2003 12:03
@Andrew11: So you think it's good that most of the time the flags
aren't documented at all??? Or that if you are lucky you read a post in a forum that a flag isn't supported right now, MAYBE in the furture??? I'm sure it will make you feel great when you waste some time on trying and learning (like you advised) and find out that it is useless what you do?? Is DB Pro your first language you tried programming with? For me it is just a tool. Not a religion. So I look which tool serves my needs the best. And with which tool I can get the job done the fastest. And for sure, this manual could have made been better. Btw. I'm new to DB Pro but not to programming at all.
Doing it for 20 years now gives me a lot experience to judge something like DB Pro.

Have a good day
Michael

Kangaroo2
23
Years of Service
User Offline
Joined: 26th Sep 2002
Location: United Kingdom
Posted: 18th Jun 2003 14:35
Probably been said already, but not everything is global (functions for example) and it does have subroutines via gosub/return

Bunnies aren't just cute like everybody supposes, They got them hoppy legs & twitchy little noses,
And what's with all the carrots? What do they need such good eyesight for anyway?

Login to post a reply

Server time is: 2026-07-11 14:55:17
Your offset time is: 2026-07-11 14:55:17