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 / arrays through functions

Author
Message
DARKBASIC PRO 3d WORLD EDITOR
13
Years of Service
User Offline
Joined: 2nd May 2012
Location:
Posted: 16th May 2015 07:53
Can you pass an array through a function? And how do array pointer work?

- Infinity is Simplicity -
Burning Feet Man
17
Years of Service
User Offline
Joined: 4th Jan 2008
Location: Sydney, Australia
Posted: 16th May 2015 10:25
If I recall correctly, a function can't return an array, it can only return a variable. However, one workaround is to set your dim your array as a global array which can then be updated by a function.

Every variable & array has a pointer, which means that with some commands you can call the pointer to that variable/array to change their content. I think you'll need Matrix Utilities for a lot of the pointer commands.

Help build an online DarkBASIC Professional help archive.
DarkBasic Help Wikia
Ortu
DBPro Master
17
Years of Service
User Offline
Joined: 21st Nov 2007
Location: Austin, TX
Posted: 16th May 2015 18:27
arrays are always global in dbpro, you don't need to pass them to a function, unless you are using abstraction where the function doesn't know or care what array it is working with, then you can pass an array pointer, which you will need to use matrix1. the matrix1 help files are good and should show everything you need to get and call the pointer

Login to post a reply

Server time is: 2025-05-12 07:43:21
Your offset time is: 2025-05-12 07:43:21