Forum Index
HomeZBasic Home   Forum RulesForum Rules   Forum FAQForum FAQ   MemberlistMemberlist   UsergroupsUsergroups   RSS FeedRSS Feed
Site SearchSite Search   LinksLinks   DownloadDownload   Digests and SubscriptionsDigests and Subscriptions
ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in   RegisterRegister
counting elements in a structure

 
Post new topic   Reply to topic    Forum Index -> ZBasic Language
Author Message
victorf



Joined: 01 Jan 2006
Posts: 342
Location: Schenectady, New York

Posted: 01 November 2006, 14:13 PM    Post subject: counting elements in a structure Reply with quote

Is there any way to find out how many data items are in a structure:

Structure MyStruct
Public a as byte
Public b as byte
Public c as byte
End Structure

This structure contains 3 data items. Can I determine that programatically?

Any enlightenment will be appreciated.

Vic
Back to top
dkinzer
Site Admin


Joined: 03 Sep 2005
Posts: 2499
Location: Portland, OR

Posted: 01 November 2006, 15:54 PM    Post subject: Re: counting elements in a structure Reply with quote

victorf wrote:
Is there any way to find out how many data items are in a structure?

Only if you know the sizes of the elements. In the example that you gave all of the elements are Byte. Consequently, SizeOf(MyStruct) \ SizeOf(Byte) is a compile-time constant that gives the number of elements.

If the structure contains elements having different sizes, the problem becomes more difficult.
Back to top
Display posts from previous:   
Post new topic   Reply to topic    Forum Index -> ZBasic Language Time synchro. with the server - Timezone/DST with your computer
Page 1 of 1

 


All content Copyright © 2005-2012 Elba Corp. All Rights Reserved.
Opinions expressed in posts are those of the author and not necessarily those of Elba Corp.
Powered by phpBB © 2001, 2005 phpBB Group