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 / DarkBasic Including Questions...

Author
Message
Shadow Robert
22
Years of Service
User Offline
Joined: 22nd Sep 2002
Location: Hertfordshire, England
Posted: 23rd Jan 2003 18:03
i never had a need to test this before my DBpro trial ran out

now i know in DarkBasic Standard and Enhanced the include files you can ONLY include functions...
which was a shame. however i remember being told that pro would have more flexability.

because of this ... can i make types in them?
can i now specify variables?
are subroutines now allowed?
array declarations?

basically i'd love to use them as an additional plugins - if not then i guess it'll have to make a seperate DBA which people cut and paste from (which kinda defeates the point!)
Anata aru kowagaru no watashi! http://members.lycos.co.uk/timesaga/darkbasic/gir.gif[/img]
The One Ring
22
Years of Service
User Offline
Joined: 15th Sep 2002
Location: United States
Posted: 23rd Jan 2003 18:07
I'm not 100% sure. I've noticed that when I define a type and an array of that type in an include file, my funcions don't recognize them.

The only fix I've found so far is to put the type and array declarations in the main DBA file.

If anyone else knows of a way around this, or perhaps knows what I could be doing wrong, please let me know. This "problem" has bugged me for a bit now.

AMD Athlon 900 768MB DDR
ATI Radeon 64MB DDR All-In-Wonder 7500, ATI XPert 128 16MB
Sound Blaster Audigy Gamer w/FireWire Support
Shadow Robert
22
Years of Service
User Offline
Joined: 22nd Sep 2002
Location: Hertfordshire, England
Posted: 23rd Jan 2003 18:30
hmm... thats what i've been afriad of
because if they're not really self contained include files the users are going to have the urge to play with the functions - piss it all up and then bitch how it doesn't work any more

Anata aru kowagaru no watashi!
Kangaroo2
22
Years of Service
User Offline
Joined: 26th Sep 2002
Location: United Kingdom
Posted: 23rd Jan 2003 19:40
"I've noticed that when I define a type and an array of that type in an include file, my funcions don't recognize them.
The only fix I've found so far is to put the type and array declarations in the main DBA file."

I have found this too - its not much of a problem for the jobs I'm doing, but yeah it would mean that un-experienced users using your functions would try and edit them. However trial and error editing is how I taught myself to make spectrum games at age 8 - and look where its got me

Shadow Robert
22
Years of Service
User Offline
Joined: 22nd Sep 2002
Location: Hertfordshire, England
Posted: 23rd Jan 2003 20:01
oki... next quesion - can i global types?

i mean i know that you can global things in functions like arrays and values - but can i global a type?

i'd hate to have to global an array or value instead of the type cause that kinda defeats the point ... and its annoying and confusing to have multiple types within the functions

Anata aru kowagaru no watashi!
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 23rd Jan 2003 20:13
You can have any number of variables in an included file. You can even create and use UDT's. UDT definitions are automatically global.
Shadow Robert
22
Years of Service
User Offline
Joined: 22nd Sep 2002
Location: Hertfordshire, England
Posted: 23rd Jan 2003 20:33
damn ... is Type are automatically global then thats the next thing i'd like added

public and private commands to superseed the types - might seem silly but i'd like them to be contained sometimes

oki for a test... i'm going to write up a quick selection of code - someone compile and upload so i can see it working just to prove its possible. I'd hate to put in like 5hours of work just to send it to KG and be told it won't compile cause of this

test.dbpro ->>


test.dba ->>


include\include.dba ->>


just cut and paste into txt files save with the extension and open in pro (or compile seperate i don't mind)

it would be helpful to actually see it working rather than just being told

Anata aru kowagaru no watashi!
regujka
22
Years of Service
User Offline
Joined: 23rd Jan 2003
Location:
Posted: 23rd Jan 2003 20:47
Please send me some examples for the shaders and the vectors! My adress: [email protected]

Shadow Robert
22
Years of Service
User Offline
Joined: 22nd Sep 2002
Location: Hertfordshire, England
Posted: 23rd Jan 2003 20:51
please don't spam the forum ... these are important questions i need answered so i know what development route to take

Anata aru kowagaru no watashi!
The One Ring
22
Years of Service
User Offline
Joined: 15th Sep 2002
Location: United States
Posted: 23rd Jan 2003 21:49
OK Vegeta. I compiled the code. In test.dba, error:

#1000006: Variable 'time' does not exist at line 38

There ya have it...

Good, bad... I'm the guy with the gun. - Ash in Army Of Darkness(1993).
Kangaroo2
22
Years of Service
User Offline
Joined: 26th Sep 2002
Location: United Kingdom
Posted: 23rd Jan 2003 21:53
Ok Vegeta currently trying this out for ya, will post a link once its uploaded

Kangaroo2
22
Years of Service
User Offline
Joined: 26th Sep 2002
Location: United Kingdom
Posted: 23rd Jan 2003 22:48
Yep i had the same problem, but I've fixed it. Vegeta there were a few small errors in your code which I changed, but some functions of it don't work. I'll attempt to explain what I have done...

1. I copied the files all into notepad and saved them as their prospective names, in
'd:\vegeta\test.dbpro'
'd:\vegeta\test.dba'
'd:\vegeta\include\include.dba'
But when I openned them up in DBPro they didn't exist (weird, but I'm sure there's a sensible reason)

2. So I started a new blank project and saved the two dba's through DBPro, and inserted your .DBPRO variables manually.

3. When I compiled I got "#1000006: Variable 'time' does not exist at line 38". Basically it wouldn't read the external DBA with the include code you wrote. I tried including it in the media and files section, and got the same result. So obviously if it WAS reading the include.dba code, it wasn't bringing back the time variable

4. I copied the contents of your include.dba file into the test.dba file, replacing the line asking it to read it externally. By the way, you missed a 'Remend' at the end of the include.dba file - no biggy, I just added it.

5. This got rid of the time variable error, but brought up another one. This was easily fixable tho...

6. The error was because you wrote
'center text sText,320,240' - when you should have written
'center text 320,240,sText' - easy mistake to make, and easy to fix

7. This time when I compiled it, it ran with no errors, but brought up a whole top screen full of "Raven Test Program" messages. Look at the code again and its easy to see why...

8. The 'print sFPS' part of the code didn't have a specified coord to print at, so the second time in the loop it would print on the 2nd line, third time the 3rd line, till it reached the bottom of the screen, and it scrolled. Hey presto, the "Raven Test Program" was moved up one space, and a replacement was added. This obviously constantly happenned in the loop so you just got a vertical line of messages

9. To fix this I added the line 'set cursor 1,1' before the print statement. This fixed the problem and you just get a "Raven Test Program" message in the middle of the screen.

10. However, this isn't exactly what you want, because whilst the 'sFps' string/variable is supposedly printing at the top of the screen, it is not visible

11. With a bit of fiddling I found that sFps was actually nothing, so your declaration of it wasn't working... the only way I could find to get it to work was to declare it as a string, not a variable, so...
'sFps as string = str$(screen fps())' I changed to
'sFps$ = str$(screen fps())'
and changed...
'print sFPS' to
'print sFPS$'

12. After doing this it displayed, but not the constant FPS as I guess you were hoping for, but instead, just a single Zero. Obviously the reason for this is that rather than constantly re-declaring the sFps$ it was just declaring it once before the program loop. Obviously this could be fixed one of two ways:
A. Pu the decalration inside the 'do' and 'loop' or...
B. Replace 'print sFPS$' with 'print screen fps()'

TO SUM IT UP!
-------------
I'm guessing what you were hoping for was for "Raven Test Program" to be displayed in the middle of the screen, along with a constantly updating FPS number, with both these variables/strings declared by an external dba file, constantly updating.

The external DBA file either didn't read, or didn't bring back the strings as you wanted

By editing the program, I came up with a single DBA that gave visually the same result as you wanted, but without the method you wanted

I don't know why the external dba file seemingly didn't work, the code looks fine to me other than the small errors I pointed out and corrected. I'm afraid I don't know why, but maybe you can look again and check. Or it may be one of those "should work in theory, but a weird bug stops it" things... Sorry.

Obviously I haven't uploaded the exe, as the finished product is not doing what you want it to, its just a simple dba displaying the screen fps and a message, but not in the method you wanted to check

Kangaroo2
22
Years of Service
User Offline
Joined: 26th Sep 2002
Location: United Kingdom
Posted: 23rd Jan 2003 22:57
As a sidenote, it just occurred to me to just try running the 'include.dba' file through DBPro on its own, adding

'print sText'
'print sFps'
'wait key'

to the end of the program to see if it was getting the strings correctly. Interestingly It displayed the 'Raven Test Program' message, but no sFPS. This would lead me to believe 2 things:

1. You can't declare the screen fps() part as a string without a dollar sign. The change I made in the main program verifies this.
2. Obviously the 'Raven Test Program' was working, so either the external file wasn't running at all, OR it was running, but the variables aren't transferable from one dba to another, without first copying them to the clipboard and re-reading them. The second seems more likely, as running the external dba file didn't bring up an error, just no variables.

If you would like, I could test getting the 'Raven Test Program' variable copied to the clipboard by the external file and re-writing the main code to read it, but for tonight I don't have time

Hope this helps, sorry if I've missed anything obvious

The One Ring
22
Years of Service
User Offline
Joined: 15th Sep 2002
Location: United States
Posted: 23rd Jan 2003 23:28
Yes. If you put a variable declaration of a UDT type in an include file, the values you assign come out as nothing.

Bizzare, but that's the way it is. Maybe the DBP team needs to look at this. You would figure that you should be able to declare TYPES and instances of those types in an include file, and see them globally.

Good, bad... I'm the guy with the gun. - Ash in Army Of Darkness(1993).
Kangaroo2
22
Years of Service
User Offline
Joined: 26th Sep 2002
Location: United Kingdom
Posted: 24th Jan 2003 01:13
Thanks OneRing lol that sounds funny I'm glad I wasn't being thick and I guessed right. Obviously the way around this is to read and write to the clipboard, or even write the variable to a text file and read it. Not sure which would be quicker, but I would guess the clipboard option would be, by quite a lot

Shadow Robert
22
Years of Service
User Offline
Joined: 22nd Sep 2002
Location: Hertfordshire, England
Posted: 24th Jan 2003 01:32
lmao... well this has actually helped alot
quite frankly screw doing the clipboard cause that'll just slow the program

i'm gonna do what i wanted to in the first place and make an enum function - kinda wish i coulda used these in the included dba directly thou
shame i can't ... but atleast now i can finally get on with coding.

(as for the actual code thats what i ment in my email earlier, i compile my programs more than i save - because i work with a scheme in my head and tend to forget to do certain things if i'd of been able to compile woulda been a snap to fix what i messed up)

Anata aru kowagaru no watashi!
Kangaroo2
22
Years of Service
User Offline
Joined: 26th Sep 2002
Location: United Kingdom
Posted: 24th Jan 2003 17:39
no probs Vegeta glad I could semi-help Thanks for all your help in my project man

Login to post a reply

Server time is: 2025-05-17 06:50:21
Your offset time is: 2025-05-17 06:50:21