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 Discussion / Passing arrays from one function to the other

Author
Message
TheComet
17
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 9th May 2009 20:00
Hey guys!

How would I get this to work:



TheComet

Peachy, and the Chaos of the Gems

Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 10th May 2009 00:24
Arrays declared inside of functions are local to that function and can't be seen by the rest of the program. You'd have to declare your arrays in the main program - not within a function:



The layout of your porgram suggests something to me - though I could be completely off base - that you are trying to make a DB program that can create it's own exe by perhaps saving functions from within the program and then using #include to execute them. In case that is what you are trying, it won't work. When the DB program is first compiled, all includes are imported from the start. The compiler won't import any additional code once it is running. It only steps through what it was built with.
If I'm wrong about what you were trying, I apologize for assuming and you can just ignore this.

Enjoy your day.
That1Smart Guy
16
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Somewhere...... yep
Posted: 10th May 2009 02:08
not sure exactly wat ur askin but if ur sayin take the data from a local array and pass it into another array, to get a size 3 array from one to the other u could exit/endfunction with a value made with rgb(array(1),array(2),array(3)) then turn it back into the values with rgbr, rgbg, rgbb

sorry if thats useless

There are only 10 kinds of people in the world, those who understand binary and those who dont
TheComet
17
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 10th May 2009 10:20
Quote: "If I'm wrong about what you were trying, I apologize for assuming and you can just ignore this."


You are not that far, I am making a waypoint plugin. I want all of my commands in a nice dba file, so you can #include it into your main program and use simple commands like "load waypoints(file,object)" or "get waypoint angle x()". But for that to happen, the arrays have to be in all of the functions...

Quote: "not sure exactly wat ur askin but if ur sayin take the data from a local array and pass it into another array, to get a size 3 array from one to the other u could exit/endfunction with a value made with rgb(array(1),array(2),array(3)) then turn it back into the values with rgbr, rgbg, rgbb

sorry if thats useless"


That would be a good idea, but I am using values greater than 255 and smaller than 0, so I couldn't pass them with the rgb() command...

TheComet

Peachy, and the Chaos of the Gems

Libervurto
18
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 10th May 2009 16:00
What is stored in the array?
You could do Smartguys idea by making your own stacked variable.

Riddle: The more you take, the more you leave behind. What are they? Answer
TheComet
17
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 10th May 2009 17:42 Edited at: 10th May 2009 18:52
I have 4 arrays (the only 4 in my plugin), and I store the x,y and z positions of the waypoints in 3 arrays as floats and the array data (values between 1 and infinite) in the other array as longs(I think).

TheComet

EDIT : They are stored in ram somewhere, right? Is there a way to access them directly? Or how about writing them to a memblock? How would I do that?

Peachy, and the Chaos of the Gems

Libervurto
18
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 11th May 2009 01:37
@TheComet
Have you used memblocks with bitmaps etc before?
You'd do it like that but write your own header...
In the header we need to store how many waypoints there are.
I'll write this as a DWORD so we can have thousands!
We could also define the memory required for each waypoint in the header to allow for differently scaled worlds but I'm just going to use DWORDS for that too. So that's 3 DWORDS for x, y and z (12 bytes).


Ok that's the memblock set up. Now to read and write it we just use our references...


I hope that works I haven't tested it.

Riddle: The more you take, the more you leave behind. What are they? Answer
TheComet
17
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 14th May 2009 20:56
Thanks obese! I'll try it out and let you know if it works!

TheComet

Peachy, and the Chaos of the Gems

Login to post a reply

Server time is: 2025-06-08 05:20:35
Your offset time is: 2025-06-08 05:20:35