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 / Help with Function

Author
Message
Images on DB Classic
21
Years of Service
User Offline
Joined: 2nd Nov 2003
Location:
Posted: 7th Nov 2003 20:49
Hi there. I want to know if a function can return an array as value in the command ENDFUNCTION. This is because, I'm writting a program, where I call a function in begining of it, and then I create an array inside that function. When the function is ended, I return to the top of the program, and I want to use the array again, but then I come with the message that the array doesn't exist. Do I have to create the array outside the function, or what? Thanks.

JCRG
Hell IVIonkey
22
Years of Service
User Offline
Joined: 1st Apr 2003
Location: Outer Limits
Posted: 7th Nov 2003 21:26
Yes, declare any array outside of functions and it will become global.

Images on DB Classic
21
Years of Service
User Offline
Joined: 2nd Nov 2003
Location:
Posted: 7th Nov 2003 21:55
Thanks. I already have fixed that problem. Now I would like to know how to input an array in the Parameter List of a function. I already declared the array outside the function, what I want to know is how to write code.

(1) FUNCTION NAME(ARRAY(N)) or (2) FUNCTION NAME (ARRAY)

I've tried both ways, and it only enters the firs number in the array. For example, if I put the array (1,2,3), I only get insede the function (1,0,0). Am I doing something wrong? or is it just something that can't be done?

Thanks, again.

JCRG
JoelJ
21
Years of Service
User Offline
Joined: 8th Sep 2003
Location: UTAH
Posted: 8th Nov 2003 00:14
im not sure, but in JAVA if you wanted to pass the whole array you would just do #2. but im not sure in DB, its prolly the same.

Two words, moo.
Jess T
Retired Moderator
21
Years of Service
User Offline
Joined: 20th Sep 2003
Location: Over There... Kablam!
Posted: 8th Nov 2003 02:57
You don't need to pass the array into the function... It is global remember?
So therefore, you can have anything like:



Hope I Helped...


Team EOD :: Programmer/Logical Engineer/All-Round Nice Guy

Login to post a reply

Server time is: 2025-05-21 16:35:36
Your offset time is: 2025-05-21 16:35:36