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 / Issues creating arrays

Author
Message
i lyke pineconez
15
Years of Service
User Offline
Joined: 16th Aug 2010
Location:
Posted: 3rd Mar 2011 00:35
Recently I have been trying to use arrays, but i keep getting the error: "Array must include a set of brackets at line 173."
I am trying to create two different arrays there, the first one works fine, but apparently it doesn't like the second one, so it throws an error at me. This is what I am using:

Only the first one works, it shows the error on the second one. Is there something I am doing wrong/not doing at all? To me they look exactly the same, and I do beleive there is a set of brackets there, but i could be mistaken.

Thanks in advance
Rich Dersheimer
AGK Developer
17
Years of Service
User Offline
Joined: 1st Jul 2009
Location: Inside the box
Posted: 3rd Mar 2011 03:58 Edited at: 3rd Mar 2011 04:04
Neither one of those is valid, the error statement is just a bit confused.

An array can't be declared as type invcont or type name unless those are valid UDTs. How did you declare the original type?

It can be declared as string, as integer, etc.

Try this:



and



Neither one will compile.

But, this will compile:


And, by the way, arrays are always global, and don't need the "global" in the declaration.

i lyke pineconez
15
Years of Service
User Offline
Joined: 16th Aug 2010
Location:
Posted: 3rd Mar 2011 04:16
The types 'invcont' and 'name' have already been pre-defined in earlier parts of my code, so that shouldn't be the problem. Thats why I'm confused.

The types I used are here:
Coldfire
17
Years of Service
User Offline
Joined: 22nd Oct 2008
Location: Indiana
Posted: 3rd Mar 2011 05:48 Edited at: 3rd Mar 2011 06:05


That should do the trick. For some reason there can be a problem when assigning an array as global otherwise.

Edit: just tried to replicate it but I couldn't. I'm not sure what conditions were when I ran into a similar problem myself, but I can't reproduce it now at all. Before, I would get errors everytime I defined a global with a UDT arrays. May possibly have been a different version. Now I have no problem with using 'global dim anything.'

Also did not know arrays were all global. That is good to know.

Edit 2: Oh, I have one idea, but you probably already know. If your UDTs are in an included source file, they will be put at the end of your main source. If I'm not mistaken, UDTs must be declared previously in code. Just a wild shot. Good luck. I'm going to bed. I'm delirious and probably not making much sense anyways, lol.
i lyke pineconez
15
Years of Service
User Offline
Joined: 16th Aug 2010
Location:
Posted: 3rd Mar 2011 06:12
I still get the same error when I try to run it. I'm assuming there aren't any real easy ways to work around UDT arrays are there?
Kevin Picone
23
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Australia
Posted: 3rd Mar 2011 07:32
You don't really need to tag them global, since they'll be global by default when it's dimensioned.

Rich Dersheimer
AGK Developer
17
Years of Service
User Offline
Joined: 1st Jul 2009
Location: Inside the box
Posted: 3rd Mar 2011 15:03
Quote: "The types 'invcont' and 'name' have already been pre-defined in earlier parts of my code, so that shouldn't be the problem. Thats why I'm confused. "


You'll have to post more of your code, so we can help you spot where the error is occuring.

Quote: "I'm assuming there aren't any real easy ways to work around UDT arrays are there?"


UDT arrays are very handy. How or why do you want to "work around" them?

Sharlenwar
17
Years of Service
User Offline
Joined: 4th Mar 2009
Location:
Posted: 3rd Mar 2011 16:44
Where are you declaring your UDT's? UDT's from what I have read and heard can't be defined inside of a function. But as Rich says, it would help to have more of your code posted so we can help debug.
i lyke pineconez
15
Years of Service
User Offline
Joined: 16th Aug 2010
Location:
Posted: 4th Mar 2011 03:56
Hey all, sorry I took a while getting back. Managed to fix it somehow, not sure exactly what I changed, but it just started working after I messed with some things.
Quote: "UDT's from what I have read and heard can't be defined inside of a function."

That probably had a lot to do with it because I accidentally put the subroutine inside of a function. Didn't think it was any big deal. Derp.

Thanks for helping.
anomer
21
Years of Service
User Offline
Joined: 11th Oct 2004
Location: City of Tears
Posted: 19th Mar 2011 08:46
Arrays are global anyway.

~astro
(stands for astronomer in case you cared )

Login to post a reply

Server time is: 2026-07-17 13:58:53
Your offset time is: 2026-07-17 13:58:53