Based ByteVectorData?

Discussion about the ZBasic language including the System Library. If you're not sure where to post your message, do it here. However, do not make test posts here; that's the purpose of the Sandbox.
Post Reply
GTBecker
Posts: 616
Joined: 17 January 2006, 19:59 PM
Location: Cape Coral

Based ByteVectorData?

Post by GTBecker »

What's wrong here?

Code: Select all

	dim XVar as ByteVectorData ({ 0, 1, 2})
	dim YVar as ByteVectorData Based (XVar + 3) ({ 3, 4, 5})
Tom
dkinzer
Site Admin
Posts: 3120
Joined: 03 September 2005, 13:53 PM
Location: Portland, OR

Re: Based ByteVectorData?

Post by dkinzer »

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: Select all

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
- Don Kinzer
GTBecker
Posts: 616
Joined: 17 January 2006, 19:59 PM
Location: Cape Coral

Re: Based ByteVectorData?

Post by GTBecker »

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: Select all

	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 - ~	
Tom
dkinzer
Site Admin
Posts: 3120
Joined: 03 September 2005, 13:53 PM
Location: Portland, OR

Re: Based ByteVectorData?

Post by dkinzer »

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: Select all

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).
- Don Kinzer
Post Reply