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 / Returning multiple values from a function using array pointers

Author
Message
Bored of the Rings
17
Years of Service
User Offline
Joined: 25th Feb 2005
Location: Middle Earth
Posted: 30th Sep 2022 21:19
One way in DBPro to return multiple values from a function.

Pro Programmer / Data Scientist, languages: SAS, C++, SQL, PL-SQL, DBPro, Purebasic, JavaScript, others
James H
15
Years of Service
User Offline
Joined: 21st Apr 2007
Location: St Helens
Posted: 1st Oct 2022 15:45 Edited at: 1st Oct 2022 15:47
Nice - was wondering about this few months back but because my old PC had issues with some M1U files I had forgotten which ones worked and which ones didn't(some security fix update(s) for windows 7 stops various M1U files from working - at least I believe that's why some work some don't on account at the time windows updates was the only change to my system - this happened at least twice I can recall where additional files suddenly stopped working)

I was going through passing arrays to functions using "ref" in agk at the time so it was more of a passing thought so never bothered looking into it. Just accepted it was not possible atm and left myself open minded for an eventual DBP return, so am very pleased to see this post along with many of your previous ones.

Cheers

Edit
for the record only M1U 4 and 29 needed to compile this
Win 7 Pro 64 bit SP1, AMD A4-5300 APU 3.4GHz, 8GB DDR3, NVidia GeForce GTX 750 1GB GDDR5, ASUS A55BM-E
Bored of the Rings
17
Years of Service
User Offline
Joined: 25th Feb 2005
Location: Middle Earth
Posted: 1st Oct 2022 16:18
@James H-many thanks for your reply and kind words. Yes, I would recommend removing any dlls that aren't needed in a final project.
Pro Programmer / Data Scientist, languages: SAS, C++, SQL, PL-SQL, DBPro, Purebasic, JavaScript, others
Bored of the Rings
17
Years of Service
User Offline
Joined: 25th Feb 2005
Location: Middle Earth
Posted: 1st Oct 2022 17:41 Edited at: 1st Oct 2022 17:41
To obtain the next array index just use a variable e.g. p (position) and loop/Inc p. At the moment my example array only uses index 0, so change code to suit your needs.
tiptr = get arrayptr item ptr(tptr,p)+tfoff

Hope that makes sense.

I've also used same technique to store a memory bank for example and it's PTR/size and data.

Loads can be done with this, you might have a better way which i would love to hear from anyone who can improve.
Pro Programmer / Data Scientist, languages: SAS, C++, SQL, PL-SQL, DBPro, Purebasic, JavaScript, others

Login to post a reply

Server time is: 2023-01-28 07:29:24
Your offset time is: 2023-01-28 07:29:24