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.

Newcomers DBPro Corner / Typed array as a parameter in DBPro

Author
Message
TheBluePill
20
Years of Service
User Offline
Joined: 10th Jan 2004
Location: Arizona, USA
Posted: 11th Jan 2004 04:03
I know arrays are global by default when declared in the main code section, but I still need to pass a string array "NamesList$(10)" as a parameter to a function.

What is the syntax to create a typed array and to pass it as a parameter to a function?

The reason I need that is because I want the code to be reusable to other programs, and using global variables in functions would create a naming dependency with the new main program. Function parameters can standarize the interface between the two. Please help.

Thanks,
The Blue Pill
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 11th Jan 2004 14:22
You cannot pass arrays as parameters yet with DBPro.

For free Plug-ins, source and the DBPro Interface library for Visual C++ 6 and .NET
http://www.matrix1.demon.co.uk
AramusM
20
Years of Service
User Offline
Joined: 6th Dec 2003
Location:
Posted: 11th Jan 2004 15:01
I see you put the word "yet" in that sentence IanM, does that mean you know that passing arrays as parameters is on the way ?
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 11th Jan 2004 16:09
Well, if you don't mind using a bit of an unsupported work-around, you can simulate passing arrays by reference with my array plug-in.

This is something that Lee has also been asked about many many times, along with pass-by-reference and returning types. They will appear eventually, but maybe not by the next update (there's enough work for that update already).

For free Plug-ins, source and the DBPro Interface library for Visual C++ 6 and .NET
http://www.matrix1.demon.co.uk
TheBluePill
20
Years of Service
User Offline
Joined: 10th Jan 2004
Location: Arizona, USA
Posted: 11th Jan 2004 19:57
Thanks for the update, IanM. There was somebody in this section of the forum claiming that was possible *only* with DBPro, but did not show how. That is why I have posted this message here.

I am writing function libraries as building blocks to create a bigger program. Without an interface with parameters, using function libraries can become quite confusing when using arrays.

So, if that is not (yet) supported, what would be your suggestion for avoiding Array name dependencies when reusing libraries with another programs?

Can arrays be declared locally within a function library file? I could create a function interface that loads items to it one by one. This would (more or less) "encapsulate" the array within a library. I don't want to sound picky, but as programs grow larger, organization becomes crucial.

What is your suggestion?

Thanks,
The Blue Pill
TheBluePill
20
Years of Service
User Offline
Joined: 10th Jan 2004
Location: Arizona, USA
Posted: 11th Jan 2004 20:32
Ok, I tested declaring an array as "local" to a library, and the result is that no values can be retrieved from it from the main program through functions. Here is an example of the main program:



And here is the function library that manipulates the local array and tried to return values from it to the main program:



Is there a way around this that allows arrays to be used locally in external libraries for internal processing? I guess I am getting this all wrong. Please enlight me.

Thanks,
The Blue Pill
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 12th Jan 2004 14:39
The LOCAL keyword currently has no effect when applied to an array defined outside of a subroutine. Also when you compile your code, the editor combines all source files into a single file for compilation, so this won't do what you are trying to do anyway.

The only way for you to avoid name clashes at the moment is to use a naming convention. If you check out two pieces of code in the CodeBase you will see how I deal with it.

Floodfill - uses __ as a prefix
http://www.thegamecreators.com/?m=codebase_view&i=79f81fab338194ad84d6c1c9511dc753

A* search - uses a named prefix SEARCH_
http://www.thegamecreators.com/?m=codebase_view&i=56984d6fa64dd67ceb1e01c8d835c957

The floodfill was an early attempt to avoid the global naming problem, but now I use the system in the A* code. All arrays, variables and functions that are local to the library are prefixed.

For free Plug-ins, source and the DBPro Interface library for Visual C++ 6 and .NET
http://www.matrix1.demon.co.uk
TheBluePill
20
Years of Service
User Offline
Joined: 10th Jan 2004
Location: Arizona, USA
Posted: 13th Jan 2004 01:56
Thanks a lot, IanM. That clears my doubts about DB internal organization. Arrays *ARE* global no matter what for the purpose I had in mind. That kind of code organization will not work in DB, so I will have to rethink the whole thing to fit the way it works.

Anyway, to think of BASIC "libraries" was never something conceivable to me That was my first programming language back on the late 80's.

I guess I was trying to apply modern concepts over an old programming language, and it just won't fit. Unfortunately, judging by what I read around here, there is no plan anytime soon to have that changed.

I discovered DB quite recently and saw *great* potential on it for its amazing simplicity, but its outdated programming paradigm can compromise larger projects, making them (least to say) difficult to maintain. Bugs in the (now unsupported) official IDE are also a bit discouraging to newcomers - especially the function fold/unfold feature, which makes code refreshing unresponsive.

Nevertheless, I still believe DB could have a bright future if such issues would be addressed. Is DB by all means being discontinued?

Thanks,
The Blue Pill
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 13th Jan 2004 14:26
The compiler (although functional) is pretty much still a work in progress. You can expect things to improve as time passes.

DB isn't being discontinued as far as I know. It will probably be available for sale for as long as anyone wants it. In fact, there are some people who are still using DB in preference to DBPro while owning both.

For free Plug-ins, source and the DBPro Interface library for Visual C++ 6 and .NET
http://www.matrix1.demon.co.uk
TheBluePill
20
Years of Service
User Offline
Joined: 10th Jan 2004
Location: Arizona, USA
Posted: 14th Jan 2004 02:01
The reason I've asked if DB is being discontinued is because I do not wish to get too enthusiastic about something that is about to vanish the next day - or to have high expectations that known issues would be fixed soon.

I have been through many programming languages trying to find "the one" I want to use to create my games with:

* BASIC was cool - over 20 years ago. Lots of fun, but by then there was no DirectX anyway Had to use machine language in addition to it to program the hardware directly. Not pretty.
* "C" is great for the speed, flexibility and native DirectX access. But finding memory leaks and bug fixing in general is horrible. Nevertheless, my best games were written in it.
* VB is easy to use, but s-l-o-w. Not a good choice.
* Delphi is wonderful, but lacks decent support to DirectX. I have used DelphiX and FederationX components to get Delphi into DirectX programming, but both lack the necessary resources. A combination of both would be the ultimate tool, though, but they are mutually exclusive.

Now, I have found DB, and it's like going back in time - but with some great new DirectX features. Would be great if it would go ahead and develop to a more mature version. The Professional version does not look very "professional" when it comes to creating larger programs, since the ability to break the code into smaller parts does not really separate the code (as you kindly explained).

I would really like to invest my time on DB, but the known bugs listed around here date from as far as 2 years ago - still unfixed. That's why I suspected this was dead in the water, possibly to be discontinued.

Also, can DB be taken as a "serious" language for game writing, or is this just a fancy tool to create demos and small games? The product box mentions "create your own 3D games" with all the bells and whistles, or even business applications (my major). Isn't that a little overstating? I still have my doubts.

Thanks,
The Blue Pill
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 14th Jan 2004 14:25
DB isn't being discontinued, but it isn't being actively updated either.

All of the current development effort is going into DBPro and the FPS Creator product ... as you'll see over the next 3-6 months.

For free Plug-ins, source and the DBPro Interface library for Visual C++ 6 and .NET
http://www.matrix1.demon.co.uk

Login to post a reply

Server time is: 2024-11-26 01:29:38
Your offset time is: 2024-11-26 01:29:38