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 / commands in an array

Author
Message
Dragon slayer
19
Years of Service
User Offline
Joined: 3rd Nov 2006
Location: Bourbonnais Illinois
Posted: 13th Oct 2013 19:49
If I wanted to put commands in an array how would I do that if you even can?

I tried it this way

dim lineset1 (3)

lineset1 (0) = line 10,10,200,10
lineset1 (1) = line 10,20,200,20
lineset1 (2) = line 10,30,200,30

print lineset0 (0)
print lineset1(1)
print lineset1 (2)

wait key
WickedX
17
Years of Service
User Offline
Joined: 8th Feb 2009
Location: A Mile High
Posted: 13th Oct 2013 20:26
If the purpose is just to print the command then yes.



Unfortunately if you want to utilize the functions in the array then no. you will need to store the parameters in an array and then utilize those parameters.

Dragon slayer
19
Years of Service
User Offline
Joined: 3rd Nov 2006
Location: Bourbonnais Illinois
Posted: 13th Oct 2013 20:33
Unfortunately if you want to utilize the functions in the array then no. you will need to store the parameters in an array and then utilize those parameters.

But if I want to use the arrays in a function I could right? as long as they are global, not declared in the function. Or I could declare them in the function then use the function when needed?
Dragon slayer
19
Years of Service
User Offline
Joined: 3rd Nov 2006
Location: Bourbonnais Illinois
Posted: 13th Oct 2013 20:39
The first example did not work the way I wanted the second did.

Is that the most efficient way to do it? What if I wanted to do a screen layout using lines?
WickedX
17
Years of Service
User Offline
Joined: 8th Feb 2009
Location: A Mile High
Posted: 13th Oct 2013 20:42 Edited at: 13th Oct 2013 20:48
Quote: "But if I want to use the arrays in a function I could right? as long as they are global, not declared in the function. Or I could declare them in the function then use the function when needed?"


Yes. It is my understanding that arrays are always global.



Quote: "Is that the most efficient way to do it? What if I wanted to do a screen layout using lines?"


You could store the data in data statements as I have done above or read a saved array or read the data from a text file.

Login to post a reply

Server time is: 2026-07-06 20:15:32
Your offset time is: 2026-07-06 20:15:32