seriously, purebasic is the only one of the modern basic languages which is not allowing these two things
freebasic
Code: Select all
Dim myArray(1 To 5) As Integer => {1, 2, 3, 4, 5}
realbasic and gambas
Code: Select all
Dim i() as Integer
i = Array(1, 2, 3, 4, 5)
blitzmax
powerbasic
Code: Select all
ARRAY ASSIGN x&() = 1,2,3,4,5,6,7,8,9,10
edit:
HeX0R wrote:
I would do it like this:
Code: Select all
Dim vertices.i(20)
CopyMemory(?_VERTICES, @vertices(), ?_VERTICES_END - ?_VERTICES)
DataSection
_VERTICES:
Data.i 0, 1, 2, 3
Data.i 4, 5, 6, 7
Data.i 8, 9, 0, 9
Data.i 8, 7, 6, 5
Data.i 4, 3, 2, 1
_VERTICES_END:
EndDataSection
here is a another way to use the data section (this one directly read and write the data section)
Code: Select all
Structure buffer
StructureUnion
int.i[0]
float.f[0]
EndStructureUnion
EndStructure
DataSection
Arrayint:
Data.i 1,2,3,4,5,6,7,8,9,10
Data.i 9,8,7,6,5,4,3,2,1,0
Arrayfloat:
Data.f 1.0,1.2,1.3,1.4,1.5
EndDataSection
*my_bufferint.buffer = ?Arrayint
Debug *my_bufferint\int[0]
Debug *my_bufferint\int[8]
Debug *my_bufferint\int[12]
Debug *my_bufferint\int[15]
Debug *my_bufferint\int[19]
*my_bufferint\int[15] = 77
*my_bufferint\int[19] = 45
Debug *my_bufferint\int[15]
Debug *my_bufferint\int[19]
*my_bufferfloat.buffer = ?Arrayfloat
Debug *my_bufferfloat\float[0]
Debug *my_bufferfloat\float[1]
Debug *my_bufferfloat\float[2]
Debug *my_bufferfloat\float[3]
Debug *my_bufferfloat\float[4]
Debug *my_bufferfloat\float[5]
*my_bufferfloat\float[0] = 52.15785
*my_bufferfloat\float[1] = -454.1294
*my_bufferfloat\float[5] = (0.125+9.777)*0.7878
Debug *my_bufferfloat\float[0]
Debug *my_bufferfloat\float[1]
Debug *my_bufferfloat\float[5]
edit 2: this one should be easier to use
Code: Select all
DataSection
Arrayint:
Data.i 1,2,3,4,5,6,7,8,9,10
Data.i 9,8,7,6,5,4,3,2,1,0
Arrayfloat:
Data.f 1.0,1.2,1.3,1.4,1.5
EndDataSection
Macro ArrayWriteI(address, slot, value)
PokeI(address+(slot*4), value)
EndMacro
Macro ArrayReadI(address, slot)
PeekI(address+(slot*4))
EndMacro
;-- test
Debug ArrayReadI(?Arrayint, 0)
Debug ArrayReadI(?Arrayint, 1)
Debug ArrayReadI(?Arrayint, 2)
Debug ArrayReadI(?Arrayint, 3)
ArrayWriteI(?Arrayint, 0, 4554)
ArrayWriteI(?Arrayint, 1, 1234)
ArrayWriteI(?Arrayint, 2, 8528)
ArrayWriteI(?Arrayint, 3, 9424)
Debug ArrayReadI(?Arrayint, 0)
Debug ArrayReadI(?Arrayint, 1)
Debug ArrayReadI(?Arrayint, 2)
Debug ArrayReadI(?Arrayint, 3)