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.

AppGameKit Classic Chat / Range of indices for arrays?

Author
Message
ET3D
10
Years of Service
User Offline
Joined: 2nd Jul 2013
Location:
Posted: 7th Jul 2013 20:24
From http://appgamekit.com/documentation/principles/1_datatypes.htm it looks like an 'dim a[3]' has indices 1 to 3. From http://www.appgamekit.com/documentation/language/5_dim.htm it looks like it has indices 0 to 2. From testing it looks like it has indices 0 to 3.

So what's the official word?
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 8th Jul 2013 01:01
(I am not official, but this is how it works).

In Tier 1 ONLY, an array dimmed as 3, "dim xyz[3]" actually has four addressable points - 0 to 3.

It lets you decide whether you are working one or zero based and I think it is sort of accidental.

In Tier 2, since it is C/C++, arrays are always zero based. So an array created as 'int abc[3];' is only indexed from zero to two.

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 8th Jul 2013 06:36
DBP worked the same way, where the range was 0 to size.

Kevin Picone
21
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Australia
Posted: 8th Jul 2013 06:58
Quote: "It lets you decide whether you are working one or zero based and I think it is sort of accidental"


It's a BASIC convention.

JimHawkins
14
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 8th Jul 2013 08:36 Edited at: 8th Jul 2013 08:39
New Pascal users should note that the array bounds are defined by the programmer:



This sub-range definition is very useful for games, where you may need an invisible border around for calculating edge conditions:



-- Jim DO IT FASTER, EASIER AND BETTER WITH AppGameKit FOR PASCAL
ET3D
10
Years of Service
User Offline
Joined: 2nd Jul 2013
Location:
Posted: 8th Jul 2013 12:04
JimHawkins, this kind of array bound declaration is indeed a wanted feature for me. I googled "agk pascal" and it looks interesting. (Though I'll probably stick to pure AppGameKit Tier 1 for now for simplicity.)

Quote: "It's a BASIC convention."


I guess it is. Googled it for C64 BASIC and it was the same there. Haven't used BASIC in 25 years or so, so I forgot.
JimHawkins
14
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 8th Jul 2013 13:09
If you have paid for AppGameKit, the Pascal is in your file list

-- Jim DO IT FASTER, EASIER AND BETTER WITH AppGameKit FOR PASCAL
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 8th Jul 2013 18:15
JimHawkins, that index definition is one of the things I really miss in other languages.

I will get to Tier 3 once I get passed my current project and the one that I have committed to doing after it.

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
JimHawkins
14
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 9th Jul 2013 01:05 Edited at: 9th Jul 2013 01:08
AL - Some people think Pascal is old-fashioned. That means they don't know what it can do in modern OOP implementations. If you look at the discussion about division problems in another topic you can lots of pointless (or point-rich!) issues. With strict typing the compiler catches most errors before you get to run anything.

For example:

Integer division: C := A div B;
Floating point division: C := A / B;

The second will produce a compiler error unless C is a floating-point type: (single, double, extended)

To focus in this thread: you can declare an array of an enumerated type:



This is good because if you try to assign something outside the range the compiler will point this out. This is better than using constants.

Better still - your enumerated type can be a set of up to 256 attributes:



These language attributes, in my experience, make programming faster, clearer and more efficient. I don't want indeterministic behaviour - I want the compiler to nag me until there are no warnings or errors!

-- Jim DO IT FASTER, EASIER AND BETTER WITH AppGameKit FOR PASCAL
ET3D
10
Years of Service
User Offline
Joined: 2nd Jul 2013
Location:
Posted: 9th Jul 2013 14:53
Jim, I don't own AppGameKit yet. I'm still debating with myself whether to back AppGameKit 2 at a level which gets me AppGameKit 1.

Still, the reason I've backed AppGameKit 2 and I'm evaluating AppGameKit 1 now is that I'm looking for the path of least resistance towards multi-platform development (Android in particular). I'm an experienced programmer (mainly C++), but I want to dabble in games in my limited free time, so Tier 1 with its simple testing and deployment on Android (which I haven't personally experienced because the trial seems to not have this) has a lot of attraction to me. Pascal may be better than BASIC as a language (and I certainly feel the BASIC limitations), but would it give me the same hassle free experience?
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 9th Jul 2013 17:25
ET3D, while Pascal can be a great language to work in, the AppGameKit version is currently not up to date with the 1.08 betas. As I understand it, the developer for Tier 3 is waiting until 1.08 is in official release before doing the Pascal version (wrapper?).

And I don't know if he has committed himself to creating Tier 3 for AppGameKit V2.

I do get the impression that he worked out the one-click Android thing (I think) for AppGameKit Pascal.

And I just started wondering how he translates the array range flexibility into something the core AppGameKit stuff understands. He must be brilliant!

IMOH, Tier 2 provides so much more flexibility and control over Tier 1. I've been coding professionally for 30+ years and have worked with all of the languages under discussion here. I loved Pascal. I learned to appreciate C++. But in either case Object Oriented Programming makes everything better.

This page might give you some idea of how things 'fit' together for Tier 2 (C++) and the different platforms. I need to go over it again and make sure that it is all nice and tight. At this point, the 1.08 beta delivery is providing working templates for all platforms. So, I've been migrating the page a bit more towards how to use them as opposed to actually creating working templates and posting them.

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master

Login to post a reply

Server time is: 2024-05-03 16:30:55
Your offset time is: 2024-05-03 16:30:55