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 / Strange problem with user-defined types in functions

Author
Message
Damaniel Hackenslasher
22
Years of Service
User Offline
Joined: 16th Oct 2003
Location:
Posted: 23rd Oct 2003 08:05
While working on a project, I ran into a place where I need to create an object in a function of a user-defined type, and pass this object to another function. However, when I do this, the object doesn't seem to get passed. I've attached a small piece of sample code that does what my project code tries to do, and fails the same way. The object gets passed properly if it's created outside of the function. Also, if I access the object inside the function directly, without passing it to another function, it works (if this all sounds confusing, see the attached code snippet). Am I doing something wrong, or is it not possible to do this yet?
Damaniel Hackenslasher
22
Years of Service
User Offline
Joined: 16th Oct 2003
Location:
Posted: 23rd Oct 2003 08:07
Hmmm, it might help if I actually post the code.....

CattleRustler
Retired Moderator
22
Years of Service
User Offline
Joined: 8th Aug 2003
Location: case modding at overclock.net
Posted: 23rd Oct 2003 10:05
me thinks you can't instance the object from within the function. If me members correct, the object(type) is global (whether or not you want it to be) but the instantiation of it in the function conflicts as the function thinks it's local

try making the object live outside the function.

sorry if wrong--me tries me tries master, my precious

-RUST-
Damaniel Hackenslasher
22
Years of Service
User Offline
Joined: 16th Oct 2003
Location:
Posted: 23rd Oct 2003 10:14
Actually, that's what I ended up doing. I just made a global object and used it within the function. The only reason I'm doing this at all is to work around another bug having to do with passing user-defined type array elements to functions. It's not the prettiest code, but it works...

Login to post a reply

Server time is: 2026-07-26 05:22:43
Your offset time is: 2026-07-26 05:22:43