Code: Select all
DataSection
Object:
Data.l[3] ;/ x, y, z
Data.l[2] ;/ max length
Data.l[5] ;/ local object data
Object_string:
Data.s[16],[26],[3] ;/ object name, description, 3-char code
EndDataSection
Code: Select all
DataSection
Object:
Data.l[3] ;/ x, y, z
Data.l[2] ;/ max length
Data.l[5] ;/ local object data
Object_string:
Data.s[16],[26],[3] ;/ object name, description, 3-char code
EndDataSection
Code: Select all
Data.b 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
Code: Select all
Data.l 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
Code: Select all
Data.s [16],[16] "abc", "qrstuvw" ; will be of same size
DataSections are writeable:Trond wrote:Maybe Mistrel hasn't noticed that DataSections are write-only? Apart from that I don't know.
Code: Select all
Define *Val.Long, Val.l
*Val = ?MyData
Restore MyData
Read.l Val
Debug Val
; Now change the Data in the DataSection
*Val\l = 123
Restore MyData
Read.l Val
Debug Val
DataSection
MyData:
Data.l 10
EndDataSection
Code: Select all
PokeL(?MyData,123)
Read.l d.l
Debug d
DataSection
MyData:Data.l 10
It is safe (in the right hands).Psychophanta wrote:Not sure, but i think datasections are read only sections, as it is part of the program body and it should not be writable.
The above example, which can be easely like this, is not safe, is it?
Code: Select all
DataSection
lbl:
Data.l 10,20,30,40,50,60
EndDataSection
Dim stuff.l(2,1)
stuff()=?lbl
Debug stuff(0,0)
stuff(0,0)=99
Debug stuff(0,0)
Do you mean something like this:Kaeru Gaman wrote:btw... It would be nice to have the possibility to assing a fully dimensionated Array to a DataSection.
I mean, Dim Array( #X, #Y ), and then bow the pointer to a DataSection
to use the Space in the Section with predefined values and don't waste space by allocating twice..
Code: Select all
Structure MyArrayRow
item.i[10]
EndStructure
Structure MyArray
row.MyArrayRow[2]
EndStructure
*myArray.MyArray = ?MyArray
For row = 0 To 1
For item = 0 To 9
Debug *myArray\row[row]\item[item]
Next
Next
; A bit easier to write with a macro
Macro ArrayItem(xArray,x,y)
xArray\row[x]\item[y]
EndMacro
For row = 0 To 1
For item = 0 To 9
Debug ArrayItem(*myArray,row,item)
Next
Next
DataSection
MyArray:
Data.i 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
Data.i 11, 12, 13, 14, 15, 16, 17, 18, 19, 20
EndDataSection