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 / Calling functions in another include file...

Author
Message
The One Ring
23
Years of Service
User Offline
Joined: 15th Sep 2002
Location: United States
Posted: 10th Apr 2003 20:54
Hello all.

I have two include files. The first has a particular function designed to load a file (by passing the filename). The second include file has a function that calls the load function from the first include file, and then does additional processing.

My problem is that the call to the first function (in the first include) from the second function (in the second include) fails. I pass a string argument to the second function, which in turn calls the first function, passing the same argument.

The first function errors and tells me the file does not exist.

If, however, I call the first function from the main DBA file (outside of any other function), this call works!!!

Has anyone else seen this? Can I not pass a parameter through more than one function?

Thanks for any help!

p.s. I also put a call to PRINT in the first function, and it shows the correct file name... bizzare!
Good, bad... I'm the guy with the gun. - Ash in Army Of Darkness(1993). http://www.divekahuna.com/images/aod-small.jpg[/img]
IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 10th Apr 2003 20:59
Can you show us in code? Just a set of examples we can paste into different files to see what the problem is.
The One Ring
23
Years of Service
User Offline
Joined: 15th Sep 2002
Location: United States
Posted: 10th Apr 2003 21:02
Sure. This first snippet is from the first include file, "XML Parser.dba". It is the load routine. Works like a champ when called from the main dba file.



This second snippet is from the include file "XML Menu.dba". This function is supposed to call the XMLLoad function (shown above), then parse the elements and store values (it's not complete yet...).



Any ideas?

Good, bad... I'm the guy with the gun. - Ash in Army Of Darkness(1993).
The One Ring
23
Years of Service
User Offline
Joined: 15th Sep 2002
Location: United States
Posted: 10th Apr 2003 21:03
Oh... the calls to "XMLSetPtr" and "XMLMovePtrForward" you can simply comment out for your testing...

Good, bad... I'm the guy with the gun. - Ash in Army Of Darkness(1993).
IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 10th Apr 2003 21:41
... and XMLGetLineCount, XMLGetElementName, XMLGetElementValue, XMLMenuSettings, XML$(), XMLLineCount() and XMLPtr() ?

Do you have anything smaller?

Here's what I've done instead:

main.dba


first.dba


second.dba


It correctly calls both functions, opens the file I've specified, and displays the contents of the first line of the file.

Can you try this code and tell us what you get?
The One Ring
23
Years of Service
User Offline
Joined: 15th Sep 2002
Location: United States
Posted: 10th Apr 2003 22:48
I tried that code. Worked. Mine still fails... Take a look at the code by downloading at http://www.geocities.com/the_one_ring/code/darkbasic/menuexample.zip.

This first half of code demonstrates the XML parser routines working. The second half tries to use the XML Menu routines, and fails...

Good, bad... I'm the guy with the gun. - Ash in Army Of Darkness(1993).
IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 10th Apr 2003 23:20
Your code fails for me when it tries to open the xml file the *second time*.

I modified my code to open the file twice too, and it still runs cleanly ... puzzling!

Still looking ...
The One Ring
23
Years of Service
User Offline
Joined: 15th Sep 2002
Location: United States
Posted: 10th Apr 2003 23:28
Thanks for the help. I want to keep the functions in seperate include files... puzzling indeed!

Good, bad... I'm the guy with the gun. - Ash in Army Of Darkness(1993).
IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 10th Apr 2003 23:40
I've put this code at the top of XMLLoad:



Again, the first time through it finds the file OK, but not the second time. I can rename the file between each load, so it's not keeping the file open in error.

I've looked throught your code closely and can see nothing that would cause this error - I think this is a bug despite the fact that I can't reproduce it in my own code.

Email this zip file to lee and see what he says (it may take him a while to respond).
The One Ring
23
Years of Service
User Offline
Joined: 15th Sep 2002
Location: United States
Posted: 11th Apr 2003 00:16
Ok. I've sent Lee a mail. I've gone over the code 100 times to see if I missed some mundane detail... I've deleted and re-created the project files... all to no avail!!!

Arrrggg!

Good, bad... I'm the guy with the gun. - Ash in Army Of Darkness(1993).
The One Ring
23
Years of Service
User Offline
Joined: 15th Sep 2002
Location: United States
Posted: 11th Apr 2003 03:17
Get this... I even put all of the XMLLoad code into the LoadMenu function. Still fails! I then hard-coded the filename into the "open file to read" function. Still fails!!!!!!!!!!!!!!!!!

Good, bad... I'm the guy with the gun. - Ash in Army Of Darkness(1993).
IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 11th Apr 2003 10:22
Sorry, I meant to say that this problem has nothing to do with being in included files.

Login to post a reply

Server time is: 2026-07-11 09:30:24
Your offset time is: 2026-07-11 09:30:24