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 / using a function to build and pass back an array of data.

Author
Message
300happy
16
Years of Service
User Offline
Joined: 21st Feb 2008
Location: Indiana, USA
Posted: 31st May 2008 22:09
I tried searching the forms, but couldn't find anything on this(it's kinda hard to search for something I don't know the keywords for.)

Simple(?) question. I have a function like so(pesudo code):



In short, I need a function that returns an array. Besides the above attempt, I've also tried:


- results in compiler error, endfunction only needs one variable. Huh?


-Same result as above.


- Results in 0, as expected, since passing an array into a non-array object returns 0.

I tried looking in the manual, but it's entry on arrays and functions isn't very helpful since the examples only use one variable to return.

How can I return the whole array back to the rest of the program?
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 1st Jun 2008 01:00
Quote: "since passing an array into a non-array object returns 0"

It may seem that way, but that's not actually what is happening.

DBPro arrays have a concept of an index - this is like a pointer to a single item within the array. You can move it to the top of the array (ARRAY INDEX AT TOP), to the bottom (ARRAY INDEX AT BOTTOM), backwards (PREVIOUS ARRAY INDEX) and forwards (NEXT ARRAY INDEX) - there are other commands that move it around too.

You access the indexed item of the array by using brackets after the array name with no index value.

So what your last piece of code was doing was retrieving the current indexed item from the array and putting the value into your 'Bob' variable.

Login to post a reply

Server time is: 2024-11-25 23:49:53
Your offset time is: 2024-11-25 23:49:53