BBC BASIC for Windows
« Initialising Structures »

Welcome Guest. Please Login or Register.
Apr 5th, 2018, 11:53pm



ATTENTION MEMBERS: Conforums will be closing it doors and discontinuing its service on April 15, 2018.
Ad-Free has been deactivated. Outstanding Ad-Free credits will be reimbursed to respective payment methods.

If you require a dump of the post on your message board, please come to the support board and request it.


Thank you Conforums members.

BBC BASIC for Windows Resources
Online BBC BASIC for Windows documentation
BBC BASIC for Windows Beginners' Tutorial
BBC BASIC Home Page
BBC BASIC on Rosetta Code
BBC BASIC discussion group
BBC BASIC for Windows Programmers' Reference

« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: Initialising Structures  (Read 472 times)
Matt
Developer

member is offline

Avatar




PM

Gender: Male
Posts: 210
xx Initialising Structures
« Thread started 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
User IP Logged

admin
Administrator
ImageImageImageImageImage


member is offline

Avatar




PM


Posts: 1145
xx Re: Initialising Structures
« Reply #1 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.
User IP Logged

Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

| |

This forum powered for FREE by Conforums ©
Terms of Service | Privacy Policy | Conforums Support | Parental Controls