Hi Charles,
I would like to assign values to a structure which holds a member with an array, something like this:
type note
int iDur
int iNote[2]
end type
note noteseq[] = {...}
but it seems that I cannot do this directly. The following approach would work for me, but maybe there is a simpler and more general way to do this? I would like to prevent wasting memory by using a second array of user defined type.
Roland
' Assigning values in udt to member with array
includepath "$/inc/"
#include "Console.inc"
type a_note
int iDur
int iNote1, iNote2
end type
a_note notes[] ={
{110, 69, 81}, {110, 67, 79}, {990, 69, 81}, {220, -1, -1}, {110, 67, 79},
{110, 65, 77}, {110, 64, 76}, {110, 62, 74}, {220, 61, 73}, {440, 62, 74},
{1980,-1, -1}, {110, 57, 69}, {110, 55, 67}, {990, 57, 69}, {220, -1, -1},
{220, 52, 64}, {220, 53, 65}, {220, 49, 61}, {440, 50, 62}, {1980, -1, -1}
}
print "spanof(notes) = " spanof(notes) cr
for x =1 to spanof(notes)
print notes[x].iDur " " notes[x].iNote1" " notes[x].iNote2 cr
next
'------------------------
type note
int iDur
int iNote[2]
end type
note noteseq[spanof(notes)]
print cr "spanof(noteseq) = " spanof(noteseq) cr
for x =1 to spanof(noteseq)
noteseq[x].iDur = notes[x].iDur
noteseq[x].iNote[1] = notes[x].iNote1
noteseq[x].iNote[2] = notes[x].iNote2
next
for x =1 to spanof(noteseq)
print noteseq[x].iDur " " noteseq[x].iNote[1] " " noteseq[x].iNote[2] cr
next
print cr "Enter ,,,"
waitkey