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 / Whatever happened to PROCEDURES

Author
Message
ager
22
Years of Service
User Offline
Joined: 3rd Jan 2003
Location: United Kingdom
Posted: 4th Jan 2003 04:56
I am new to DB and DB Pro so this may have been said before; but where is PROC...ENDPROC or some such. I haven't used Gosub since BBC BASIC introduced procedures in 1987!

There's functions is suppose but I presume they only return one value.
MrTAToad
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: United Kingdom
Posted: 4th Jan 2003 05:09
Procedures have basically been converted to functions now - you just decided whether to ignore any return value or not.

Personally, I always return something, even if its ignored - that way any future modificiations can be taken into account slightly easily.

Good news everyone! I really am THAT good...
http://www.nickk.nildram.co.uk/ for great plug-ins - oh my, yes!
firestarter
22
Years of Service
User Offline
Joined: 26th Dec 2002
Location: Norway
Posted: 4th Jan 2003 16:44
Ager: I`m not sure if it works in DB Pro, but in C++ for instance u can use pointers as arguments in functions so that the things you do in the function can be returned to the memory position(s) the pointer(s) point at. That means
that u can return more than 1 value.


You can for instance make a pointer in this way (i think) in DB Pro:

MyDataPointer = MAKE MEMORY(1)

MyDataPointer will hold a memory value, and the 1 stands for 1 byte.

To put a value in that position use * infront of the pointer name. *MyDataPointer = 200 for instance.

firestarter
22
Years of Service
User Offline
Joined: 26th Dec 2002
Location: Norway
Posted: 4th Jan 2003 16:48
To use it in a function i guess you can just use

FUNCTION test(Pointertest)
*Pointertest = 220
ENDFUNCTION

test(MyDataPointer)

Print *MyDataPointer

-----------------------
I havent tested this yet, the syntax could be wrong.

MrTAToad
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: United Kingdom
Posted: 4th Jan 2003 17:06
The even easier way is to use my peek/poke commands...

Good news everyone! I really am THAT good...
http://www.nickk.nildram.co.uk/ for great plug-ins - oh my, yes!
Benjamin
22
Years of Service
User Offline
Joined: 24th Nov 2002
Location: France
Posted: 4th Jan 2003 17:12
procedures...DLLprocedures....ive seen 'em all.....DLL ones are only for making DLLs though...

xxxpetratxxx
B. R. W
ager
22
Years of Service
User Offline
Joined: 3rd Jan 2003
Location: United Kingdom
Posted: 4th Jan 2003 18:07
Having spent a few days reading other peoples code they tends to be made up of Gosubs not Functions. Gosubs of course tend to use variables declared or amended outside the subroutine that are by definition global. In VB6 for example you would pass these into the subroutine via a SUB's parameter list (thus privatising the global for use in the routine). This has a number of advantages not least of which it is easy to see what variables each subroutine is using and you can choose whether to pass the variable back unchanged or changed. Good programming practice and all that.

Notwithstanding this, DBPro looks a damn fine language.

MrTAToad
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: United Kingdom
Posted: 4th Jan 2003 19:49
Yes, its best to use local variables where possible - can save a lot of trouble...

Good news everyone! I really am THAT good...
http://www.nickk.nildram.co.uk/ for great plug-ins - oh my, yes!
ICERGB
22
Years of Service
User Offline
Joined: 8th Nov 2002
Location: Canada
Posted: 6th Jan 2003 05:23
and if you like C please do not encourage the corruption Dark Basic.

That's what high end C++ is for!

Look what they did to the flash programming variables in Flash 5 just because all these 3year C++ programmers came around and complained!

I just cannot ever imagine using ++ to add a variable in DBPro without throwing a fit and dieing of convulsions OK?
indi
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 6th Jan 2003 05:48
u can use global arrays declared at the top of your app across functions globally to return results without having to use the return parameter in the function, allowing for more than one returned variable.

ICERGB
22
Years of Service
User Offline
Joined: 8th Nov 2002
Location: Canada
Posted: 6th Jan 2003 07:37
Yes, global arrays, not mentioned in the DBPro manual
for functions only.
what was the new command?
ICERGB
22
Years of Service
User Offline
Joined: 8th Nov 2002
Location: Canada
Posted: 6th Jan 2003 07:46
was it;
global a#


???
Digital Awakening
AGK Developer
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Sweden
Posted: 6th Jan 2003 16:33
Gosubs are great just because it uses global variables. So far my game The Magic Land (shots and info on my site) Uses 14 gosubs and no functions. If you want local variables use functions.

[b]Digital Awakening
Game in developement: 3D RPG - The Magic Land
Visit DigAw.com for more info and shots
MrTAToad
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: United Kingdom
Posted: 6th Jan 2003 16:46
Each to their own...

Good news everyone! I really am THAT good...
http://www.nickk.nildram.co.uk/ for great plug-ins - oh my, yes!
heartbone
22
Years of Service
User Offline
Joined: 9th Nov 2002
Location:
Posted: 7th Jan 2003 07:02
I'm with you ager.
I MISS <PROCEDURE> ---- <END PROCEDURE> VERY MUCH.
Functions do not replace them.
Procedure have the modularity of a function
AND
the ability to pass back multiple variables, NOT JUST ONE.

AMOS the direct ancestor of DarkBASIC had both procedures and functions, but either Lee or Microcrap Visual Studio must have had issues with them. Way too bad.

The more you see, the more you know.
The more you know, the more you see.
MrTAToad
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: United Kingdom
Posted: 7th Jan 2003 13:07
Never knew the BBC ENDPROC command could return back multiple values - how did it do that ?

Good news everyone! I really am THAT good...
http://www.nickk.nildram.co.uk/ for great plug-ins - oh my, yes!
TheCyborg
22
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Denmark
Posted: 7th Jan 2003 14:13
I found a way to make a function return more than one value.

(I dont think this function work. Just to show what I mean.)
Function getDimensions$(objNum)
x=Object Width(objNum)
y=Object Height(objNum)
z=Object Depth(objNum)
OutPut$=str$(x)+","+str$(y)+";"+str$(z)
EndFunction OutPut$

This would make a return string something like this:
100,200;150

Then I made two functions that could return the seperate parts of that string, "GetBefore" & "GetAfter".

ex:
Test$=GetDimensions(1)
DimensionX=Val(GetBefore(",",Test$))
DimensionY=Val(GetAfter(",",GetBefore(";",Test$)))
DimensionZ=Val(GetAfter(";",Test$))

I dont remember the GetBefore/After Functions, you have to figure them out yourself. But that should do the trick. I have used this method in lots of my apps/games.

TheCyborg Development.
http://TheCyborg.Amok.dk
The Ultimate Source To DarkBASIC Programming.
MrTAToad
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: United Kingdom
Posted: 7th Jan 2003 14:23
Quite an interesting way of doing it... Inefficient, but clever...

Good news everyone! I really am THAT good...
http://www.nickk.nildram.co.uk/ for great plug-ins - oh my, yes!
ager
22
Years of Service
User Offline
Joined: 3rd Jan 2003
Location: United Kingdom
Posted: 20th Jan 2003 20:14
MrTAToad is not correct BBC Basic can return multiple variables by putting RETURN before the variable in the parameter list; later Basics can as well, notably VB - <Sub> <End Sub>

MrTAToad
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: United Kingdom
Posted: 20th Jan 2003 22:56
The BBC Basic on the Archimedes computers couldn't, so have you got an example for the BBC Basic ?

Good news everyone! I really am THAT good...
http://www.nickk.nildram.co.uk/ for great plug-ins - oh my, yes!
Shadow Robert
22
Years of Service
User Offline
Joined: 22nd Sep 2002
Location: Hertfordshire, England
Posted: 20th Jan 2003 23:56


and you can export 255 of whatever you like out, plus you still have the actual Return for error debugging

sorry to say it though, but languages grow up in thier own way ... just because some of the team worked on and|or for AMOS, doesn't mean that it is the evolved version for the PC.

This is a new language and if after 4years everyone can't get used to that, then probably time they left the language be.
Unless DarkBasic Professional or the nexgen of this lanuage becomes equal to C/C++ in power and depth, you will always have to look at the language AS a stepping stone towards these on a professional level.
And even if you want to enhance the actual program itself, you still need to understand C/C++ and preferablly DirectX programming to enhance it properly.

all i'm saying is get used to what you have, but i'm sure more things will arrive (me hopes Classes along with Private and Public access for functions, types and classes).

Anata aru kowagaru no watashi!
ager
22
Years of Service
User Offline
Joined: 3rd Jan 2003
Location: United Kingdom
Posted: 28th Jan 2003 03:16
MrTAToad oh yes BBC Basic could; trivial example from Archimedes Basic Guide 1988 - Pg 87:

100 DEF PROCorederedswap (RETURN A, RETURN B)
110 IF A > B SWAP A,B
120 ENDPROC

indi
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 28th Jan 2003 05:33
u can return multiple variables inside typed arrays and types, like i explained before.

MrTAToad
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: United Kingdom
Posted: 28th Jan 2003 10:53
Well, I never knew that. As I never had the BBC BASIC book (just the 4 volume reference guide), I had to go by the internal help system...

Good news everyone! I really am THAT good...
http://www.nickk.nildram.co.uk/ for great plug-ins - oh my, yes!

Login to post a reply

Server time is: 2025-05-19 05:54:03
Your offset time is: 2025-05-19 05:54:03