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 AppGameKit Corner / Array - defining with new system doesn't work for me?!?!!?

Author
Message
DavidAGK
AGK Developer
10
Years of Service
User Offline
Joined: 1st Jan 2014
Location:
Posted: 24th Apr 2016 14:18
If I write "Button As Integer[3]" I get an error - ""Button not defined"
If I write "Dim Button[3]" it compiles fine.....

So the old school method seems to work fine but the new one doesn't. Seems so simple and it must be me....but what am I doing wrong?
Using Tier 1 AppGameKit V2
Started coding with AMOS (Thanks Francois Lionet)
Fluorescent
FPSC Reloaded TGC Backer
19
Years of Service
User Offline
Joined: 1st Aug 2005
Location: Stockholm, Sweden
Posted: 24th Apr 2016 14:23
It works for me, does your code contain an user type or something already called Button?
DavidAGK
AGK Developer
10
Years of Service
User Offline
Joined: 1st Jan 2014
Location:
Posted: 24th Apr 2016 16:04
No. It's weird that it's never worked for me...I'm on 2017.
Using Tier 1 AppGameKit V2
Started coding with AMOS (Thanks Francois Lionet)
janbo
16
Years of Service
User Offline
Joined: 10th Nov 2008
Location: Germany
Posted: 24th Apr 2016 22:49
Do you use the Array in the same scope only ?
If not make it global.

Using AGKv2 Tier1
Dybing
13
Years of Service
User Offline
Joined: 12th Sep 2011
Location: Bergen, Norway
Posted: 25th Apr 2016 02:19
Just to embellish a bit on what janbo said...

If you use the old method, your array automagically becomes a global, whereas with the new method it is treated like any other variable or datatype, and will only work within the scope it was defined or/and passed into.

So whilst this will result in an error:



The following code however will pass myArray to the function. Unlike datatypes, where you pass by referencing the name of the datatype, with arrays, you need say of what type it is (integer, string, float) followed by [] to signify it is an array when declaring it in the function-header.



You could of course also just define your array to be global like so:



But globals can be a problem in larger projects. For smaller projects, it's fine.
DavidAGK
AGK Developer
10
Years of Service
User Offline
Joined: 1st Jan 2014
Location:
Posted: 25th Apr 2016 17:15
Aah! Cheers guys. I get it now!
Using Tier 1 AppGameKit V2
Started coding with AMOS (Thanks Francois Lionet)

Login to post a reply

Server time is: 2024-11-21 20:18:40
Your offset time is: 2024-11-21 20:18:40