Data statement

In this category you can exchange your programming questions and solutions.
Post Reply
bob82604
Posts: 1
Joined: Tue Jan 08, 2019 4:20 am

Data statement

Post: # 98384Post bob82604
Sat Jul 16, 2022 1:54 am

What can I use to prefill a 6x13 byte array?
There is no data statement, so at a loss here.
(I may have asked this a long time ago LOL)

EricE
Posts: 2
Joined: Wed Jul 27, 2022 3:35 am

Re: Data statement

Post: # 98387Post EricE
Tue Aug 09, 2022 6:00 am

Here is a program that will intialize an array using data stored in strings.
Note that FNXBasic stores arrays in column order.
------------------------------------------------------------

' File: ArrayData.bas
'
' Filling a 6x13 byte array
' FNXBasic stores arrays by column

'--------------------
' columns of data
Dim Data(13) as String

' column data strings
Data(0) = CHR$(&h00)+CHR$(&h10)+CHR$(&h20)+CHR$(&h30)+CHR$(&h40)+CHR$(&h50)
Data(1) = CHR$(&h01)+CHR$(&h11)+CHR$(&h21)+CHR$(&h31)+CHR$(&h41)+CHR$(&h51)
Data(2) = CHR$(&h02)+CHR$(&h12)+CHR$(&h22)+CHR$(&h32)+CHR$(&h42)+CHR$(&h52)
Data(3) = CHR$(&h03)+CHR$(&h13)+CHR$(&h23)+CHR$(&h33)+CHR$(&h43)+CHR$(&h53)
Data(4) = CHR$(&h04)+CHR$(&h14)+CHR$(&h24)+CHR$(&h34)+CHR$(&h44)+CHR$(&h54)
Data(5) = CHR$(&h05)+CHR$(&h15)+CHR$(&h25)+CHR$(&h35)+CHR$(&h45)+CHR$(&h55)
Data(6) = CHR$(&h06)+CHR$(&h16)+CHR$(&h26)+CHR$(&h36)+CHR$(&h46)+CHR$(&h56)
Data(7) = CHR$(&h07)+CHR$(&h17)+CHR$(&h27)+CHR$(&h37)+CHR$(&h47)+CHR$(&h57)
Data(8) = CHR$(&h08)+CHR$(&h18)+CHR$(&h28)+CHR$(&h38)+CHR$(&h48)+CHR$(&h58)
Data(9) = CHR$(&h09)+CHR$(&h19)+CHR$(&h29)+CHR$(&h39)+CHR$(&h49)+CHR$(&h59)
Data(10) = CHR$(&h0A)+CHR$(&h1A)+CHR$(&h2A)+CHR$(&h3A)+CHR$(&h4A)+CHR$(&h5A)
Data(11) = CHR$(&h0B)+CHR$(&h1B)+CHR$(&h2B)+CHR$(&h3B)+CHR$(&h4B)+CHR$(&h5B)
Data(12) = CHR$(&h0C)+CHR$(&h1C)+CHR$(&h2C)+CHR$(&h3C)+CHR$(&h4C)+CHR$(&h5C)
'--------------------

Dim myArray(6,13) as byte
Dim memAddress1 as integer
Dim memAddress2 as integer
Dim i as integer
Dim j as integer

print "Starting"

' fill byte array with data, column by column
for j=0 to 12
memAddress1 = varptr(myArray(0,j))
memAddress2 = varptr(Data(j))
memcopy memAddress1, memAddress2,6
next j

print "myArray"
print

for i=0 to 5
for j=0 to 12
print hex$(myArray(i,j),2)+" ";
next j
print
next i

While inkey$="":Wend

Post Reply