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
Based ByteVectorData?

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



Joined: 18 Jan 2006
Posts: 457
Location: Cape Coral

Posted: 22 December 2009, 0:16 AM    Post subject: Based ByteVectorData? Reply with quote

What's wrong here?

Code:
   dim XVar as ByteVectorData ({ 0, 1, 2})
   dim YVar as ByteVectorData Based (XVar + 3) ({ 3, 4, 5})
Back to top
dkinzer
Site Admin


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

Posted: 22 December 2009, 1:50 AM    Post subject: Re: Based ByteVectorData? Reply with quote

GTBecker wrote:
What's wrong here?
It just isn't supported. A based variable has no space allocated for it - it's simply an overlay on some other memory. Since there is no space allocated, there is no way to define content as you're trying to do.

I take it that you're trying to ensure that the data for XVar and YVar are contiguous. If they are defined contiguously they will be allocated contiguously in VM mode and probably so in native mode, too. In any event, you can accomplish the same goal (if I understand it correctly) with the following code:
Code:
Dim rawData as ByteVectorData ({ 0, 1, 2, 3, 4, 5 })
Dim XVar() as ProgMem Byte Based rawData.DataAddress + 0
Dim YVar() as ProgMem Byte Based rawData.DataAddress + 3

Sub Main()
  Dim i as Integer
  Debug.Print "XVar = ";
  For i = 1 to 3
    If (i > 1) Then
      Debug.Print ", ";
    End If
    Debug.Print XVar(i);
  Next i
  Debug.Print
  Debug.Print "YVar = ";
  For i = 1 to 3
    If (i > 1) Then
      Debug.Print ", ";
    End If
    Debug.Print YVar(i);
  Next i
End Sub
Back to top
GTBecker



Joined: 18 Jan 2006
Posts: 457
Location: Cape Coral

Posted: 22 December 2009, 4:47 AM    Post subject: Re: Based ByteVectorData? Reply with quote

dkinzer wrote:
I take it that you're trying to ensure that the data for XVar and YVar are contiguous.


Yes. I encountered an error (line >1023 bytes) and split it up into two Dims - which seemed to not be placed in contiguous code space on a ZX-24.

The trailing comments on the first two lines here evoke the too-long line error, although it seems that the character count shouldn't be that high. Does the indent spacing count?

Code:
   dim OSDCharTable as bytevectordata ({&h42,&h42,&h42,&h42,&h42,&h42,&h42,&h42, _   ' ........
                              &h42,&h42,&h42,&h42,&hec,&hed,&hee,&hef, _   ' ........
                              &hf0,&hf1,&hf2,&hf3,&hf4,&hf5,&hf6,&hf7, _
                              &hf8,&hf9,&hfa,&hfb,&hfc,&hfd,&hfe,&hff, _
                              &h00,&h42,&h48,&h42,&h42,&h42,&h42,&h46, _   ' space - '
                              &h3f,&h40,&h42,&h42,&h45,&h49,&h41,&h47, _   ' ( - /
                              &h0A,&h01,&h02,&h03,&h04,&h05,&h06,&h07, _   ' 0 - 7
                              &h08,&h09,&h44,&h43,&h4a,&h42,&h4b,&h42, _   ' 8 - ?
                              &h4c,&h0b,&h0c,&h0d,&h0e,&h0f,&h10,&h11, _   ' @ - G
                              &h12,&h13,&h14,&h15,&h16,&h17,&h18,&h19, _    ' H - O
                              &h1a,&h1b,&h1c,&h1d,&h1e,&h1f,&h20,&h21, _    ' P - W   
                              &h22,&h23,&h24,&h42,&h42,&h42,&h42,&h42, _    ' X - _   
                              &h42,&h25,&h26,&h27,&h28,&h29,&h2a,&h2b, _    ' ` - g   
                              &h2c,&h2d,&h2e,&h2f,&h30,&h31,&h32,&h33, _    ' h - o   
                              &h34,&h35,&h36,&h37,&h38,&h39,&h3a,&h3b, _    ' p - w   
                              &h3c,&h3d,&h3e,&h42,&h42,&h42,&h42,&h42})   ' x - ~   
Back to top
dkinzer
Site Admin


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

Posted: 22 December 2009, 5:07 AM    Post subject: Re: Based ByteVectorData? Reply with quote

GTBecker wrote:
Does the indent spacing count?
Yes, it does. The lexical analyzer doesn't know anything about the content of a line before it reads it in.

I think that you can easily work around the problem by removing the line-continuation underscores. The initialization data for a Program Memory data item is allowed to span multiple lines without using a line-continuation character. For example:
Code:
Dim rawData as ByteVectorData ({
   0,
   1, 2, 3,
   4,
   5
})
The other option, of course, is to put the initialization data in a separate file (as you must do with BasicX).
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