month one less than expected (Program Bug and Problems)

by gyorgy.miklos, Tuesday, March 04, 2014, 07:29 (1147 days ago)

Hi,

I just noticed that the built-in variable month returns a number in the 0..11 range, which is one less then expected in the 1..12 range. day works fine.

This is for version 1.1.0.0 running on Windows 7.

Best regards,
--György
(Budapest)

month one less than expected

by Jim ⌂ @, Russell, KY, Tuesday, March 04, 2014, 17:39 (1147 days ago) @ gyorgy.miklos

Actually that is the correct behavior as it was programmed and documented. see http://doc.basic256.org/doku.php?id=en:month

Jim

month one less than expected

by gyorgy.miklos, Wednesday, March 05, 2014, 08:03 (1146 days ago) @ Jim

I see - thanks. Then this is just rather counter intuitive, especially for children. Anyway, it is easy thing to solve.

Regards,
//György

month one less than expected

by Andrew360 @, Tuesday, March 11, 2014, 22:07 (1140 days ago) @ gyorgy.miklos

On most programming languages, indices begin on zero. This means that instead of counting from 1 to 100, it would count from 0 to 99. One example is plotting on the screen - (0,0) is top left and (299,299) is bottom right.

Another example is arrays. If an array had 5 elements, the first would be written as array[0] and the last would be array[4]. So if it had twelve elements you could do this:

months$={"Jan","Feb","March", "April","May","June", "July","Aug","Sept", "Oct","Nov","Dec"}
print months$[month]

RSS Feed of thread
powered by my little forum