BBC BASIC for Windows
Programming >> BBC BASIC language >> Initialising Structures
http://bb4w.conforums.com/index.cgi?board=language&action=display&num=1285393138

Initialising Structures
Post by Matt on Sep 25th, 2010, 05:38am

Hi,
The BB4W help explains how to initialise arrays:

A%() = 1, 2, 3, 4, 5
B$() = "Alpha", "Beta", "Gamma", "Delta"
C() = PI


But this doesn't seem to be the case with structures:

structure.A%() = 1, 2, 3, 4, 5
structure.B$() = "Alpha", "Beta", "Gamma", "Delta"
structure.C() = PI


Is this so, or am I missing something?

Matt
Re: Initialising Structures
Post by admin on Sep 25th, 2010, 08:32am

on Sep 25th, 2010, 05:38am, Matt wrote:
The BB4W help explains how to initialise arrays: But this doesn't seem to be the case with structures: Is this so, or am I missing something?

You're quite right. Arrays within structures have a different memory layout to 'regular' arrays, and none of the 'whole array' operations work with them. This is documented in the manual as follows: "Normally a structure member can be treated in exactly the same way as a simple variable of the same type. However this is not so in the case of operations on entire arrays or entire structures which cannot be used with structure members":

http://www.bbcbasic.co.uk/bbcwin/manual/bbcwin2.html#members

It's an unfortunate consequence of the way structures were 'bolted on' to a language which wasn't originally designed with them in mind.

Richard.