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 / Problems with passing data to functions

Author
Message
Programmer of Power
19
Years of Service
User Offline
Joined: 22nd Aug 2005
Location: Home
Posted: 4th Jun 2008 03:24


Alright there's my function. And the error is with these lines

I'm calling the function with this call
but I keep getting an error stating that the object number is illegal. I do in fact have an object 1 [its a box] and if I change the number in the function to 1 then the program works fine. Any idea what the problem might be?

"I will work harder... if you ask me enough times... or give me enough coffee"
Zergei
19
Years of Service
User Offline
Joined: 9th Feb 2005
Location: Everywhere
Posted: 4th Jun 2008 04:18 Edited at: 4th Jun 2008 04:19
Problem might be here: (within the function)



I don't see you setting that variable to anything, so it'll end up with 0. Maybe you wanted it to say:



Hope it helps...

Further on my stuff at...
TurboSquid.com
The3dStudio.com
Programmer of Power
19
Years of Service
User Offline
Joined: 22nd Aug 2005
Location: Home
Posted: 4th Jun 2008 04:29
I've got the variable initialized elsewhere in the code and I've tried changing that initialization to different numbers, and following it through the code. The variable has a value, but it doesn't seem to be passed to the function... and I'm really confused as to why.

"I will work harder... if you ask me enough times... or give me enough coffee"
pcRaider
17
Years of Service
User Offline
Joined: 30th May 2007
Location:
Posted: 4th Jun 2008 07:12
You have to learn you about "scope of variable".

Programmer of Power
19
Years of Service
User Offline
Joined: 22nd Aug 2005
Location: Home
Posted: 5th Jun 2008 03:54
I'm not trying to use the variable outside of the function though... I'm passing a direct value, in this case, 1.

And I don't use the variable 'parentObjNumber' anytime other than within that function.

When I step through the code, object 1 is created, objects 2 and 3 are created, and then when I call my lines function which is to draw a line between each object, it states that the object number is illegal.

I'm beginning to think this might be some sort of obscure bug? *gasp*

"I will work harder... if you ask me enough times... or give me enough coffee"
BMacZero
18
Years of Service
User Offline
Joined: 30th Dec 2005
Location: E:/ NA / USA
Posted: 5th Jun 2008 04:03
I'm thinking the problem is with that i, you might try running it in step-through-mode at a slow speed and watching it in the Variable Watcher.

Los Mineros are back in progress!
Programmer of Power
19
Years of Service
User Offline
Joined: 22nd Aug 2005
Location: Home
Posted: 5th Jun 2008 05:21
Ah I thought it might be that as well... except that the 'i' variable is also used in the 2 previous lines of the code [completing a similar task that it would be doing in the next parts.

works fine.

The error occurs with


"I will work harder... if you ask me enough times... or give me enough coffee"
Zergei
19
Years of Service
User Offline
Joined: 9th Feb 2005
Location: Everywhere
Posted: 5th Jun 2008 06:19
Is there a possibility we could get a full view of the code?

Further on my stuff at...
TurboSquid.com
The3dStudio.com
Programmer of Power
19
Years of Service
User Offline
Joined: 22nd Aug 2005
Location: Home
Posted: 6th Jun 2008 02:13 Edited at: 6th Jun 2008 02:28
Yeah sure. It's not too long... and hopefully not complicated. Mostly function calls.



"I will work harder... if you ask me enough times... or give me enough coffee"
Zergei
19
Years of Service
User Offline
Joined: 9th Feb 2005
Location: Everywhere
Posted: 6th Jun 2008 05:41 Edited at: 6th Jun 2008 05:43
Sorry for repeating myself, but maybe i explained myself poorly last time.

On the code you supplied us, what would be line 61, that is within this function:



the line:

makeSub(name$, parent, i)

you are autocalling that same function. No problem on doing that, but the variable "parent" doesn't appear anywhere else but there. No global/local instanciation or use of it anywhere. So may guess is that maybe it was mistaken for another variable. Maybe "parentObjNumber" ?
Do tell me if im wrong or something.

Btw, i changed it to "parentObjNumber", ran the code and, something happened, thought i don't know if its what it was expected to happen...

Hope it helps...

Further on my stuff at...
TurboSquid.com
The3dStudio.com
Programmer of Power
19
Years of Service
User Offline
Joined: 22nd Aug 2005
Location: Home
Posted: 6th Jun 2008 06:13
Wow. Yes that's exactly what the problem was, and I misread your first post. Thanks a lot. It's always something small that throws an entire thing off. Gracias.

"I will work harder... if you ask me enough times... or give me enough coffee"

Login to post a reply

Server time is: 2024-09-27 16:23:31
Your offset time is: 2024-09-27 16:23:31