203 lines
3.5 KiB
Plaintext
203 lines
3.5 KiB
Plaintext
window 1, @"FutureBasic Arrays", (0,0,480,450)
|
|
|
|
begin globals
|
|
dynamic gA1(10) as long
|
|
dynamic gA2(10) as Str255
|
|
end globals
|
|
|
|
void local fn CType
|
|
long i
|
|
|
|
text ,, fn ColorGray
|
|
print @"// C-type fixed-length"
|
|
text
|
|
long a1(4)
|
|
a1(0) = 10
|
|
a1(1) = 5
|
|
a1(2) = 12
|
|
a1(3) = 8
|
|
a1(4) = 7
|
|
for i = 0 to 4
|
|
print a1(i),
|
|
next
|
|
print
|
|
|
|
a1(0) = 24
|
|
a1(2) = 18
|
|
a1(4) = 76
|
|
for i = 0 to 4
|
|
print a1(i),
|
|
next
|
|
print
|
|
|
|
CFStringRef a2(4)
|
|
a2(0) = @"Alpha"
|
|
a2(1) = @"Bravo"
|
|
a2(2) = @"Tango"
|
|
a2(3) = @"Delta"
|
|
a2(4) = @"Echo"
|
|
for i = 0 to 4
|
|
print a2(i),
|
|
next
|
|
print
|
|
|
|
a2(2) = @"Charlie"
|
|
for i = 0 to 4
|
|
print a2(i),
|
|
next
|
|
print : print
|
|
end fn
|
|
|
|
void local fn CTypeDynamic
|
|
long i
|
|
|
|
text ,, fn ColorGray
|
|
print @"// C-type dynamic"
|
|
text
|
|
gA1(0) = 46
|
|
gA1(1) = 38
|
|
gA1(10) = 67
|
|
for i = 0 to fn DynamicNextElement( dynamic(gA1) ) - 1
|
|
print gA1(i),
|
|
next
|
|
print
|
|
|
|
gA1(5) = 19
|
|
gA1(10) = 22
|
|
for i = 0 to fn DynamicNextElement( dynamic(gA1) ) - 1
|
|
print gA1(i),
|
|
next
|
|
print
|
|
|
|
gA2(0) = "Kilo"
|
|
gA2(1) = "Lima"
|
|
gA2(5) = "Mike"
|
|
for i = 0 to fn DynamicNextElement( dynamic(gA2) ) - 1
|
|
print gA2(i),
|
|
next
|
|
print
|
|
|
|
gA2(1) = "November"
|
|
gA2(6) = "Oscar"
|
|
for i = 0 to fn DynamicNextElement( dynamic(gA2) ) - 1
|
|
print gA2(i),
|
|
next
|
|
print : print
|
|
end fn
|
|
|
|
void local fn CoreFoundationImmutable
|
|
long i
|
|
|
|
text ,, fn ColorGray
|
|
print @"// CoreFoundation (CF) immutable"
|
|
text
|
|
CFArrayRef a5 = @[@10,@5,@12,@8,@7]
|
|
for i = 0 to 4
|
|
print a5[i],
|
|
next
|
|
print
|
|
|
|
CFArrayRef a6 = @[@"Alpha",@"Bravo",@"Charlie",@"Delta",@"Echo"]
|
|
for i = 0 to 4
|
|
print a6[i],
|
|
next
|
|
print : print
|
|
end fn
|
|
|
|
void local fn CoreFoundationMutableFixedLength
|
|
long i
|
|
|
|
text ,, fn ColorGray
|
|
print @"// CoreFoundation (CF) mutable, fixed-length"
|
|
text
|
|
CFMutableArrayRef a1 = fn MutableArrayWithCapacity(3)
|
|
MutableArrayAddObject( a1, @79 )
|
|
MutableArrayAddObject( a1, @43 )
|
|
MutableArrayAddObject( a1, @101)
|
|
for i = 0 to len(a1) - 1
|
|
print a1[i],
|
|
next
|
|
print
|
|
|
|
MutableArrayReplaceObjectAtIndex( a1, @15, 2 )
|
|
for i = 0 to len(a1) - 1
|
|
print a1[i],
|
|
next
|
|
print
|
|
|
|
CFMutableArrayRef a2 = fn MutableArrayWithCapacity(4)
|
|
MutableArrayAddObject( a2, @"Whisky" )
|
|
MutableArrayAddObject( a2, @"Oscar" )
|
|
MutableArrayAddObject( a2, @"Yankee" )
|
|
MutableArrayAddObject( a2, @"Sierra" )
|
|
for i = 0 to len(a2) - 1
|
|
print a2[i],
|
|
next
|
|
print
|
|
|
|
MutableArrayReplaceObjectAtIndex( a2, @"Xray", 1 )
|
|
MutableArrayReplaceObjectAtIndex( a2, @"Zulu", 3 )
|
|
for i = 0 to len(a2) - 1
|
|
print a2[i],
|
|
next
|
|
print : print
|
|
end fn
|
|
|
|
void local fn CoreFoundationMutableDynamic
|
|
long i
|
|
|
|
text ,, fn ColorGray
|
|
print @"// CoreFoundation (CF) mutable, dynamic"
|
|
text
|
|
CFMutableArrayRef a1 = fn MutableArrayWithCapacity(0)
|
|
MutableArrayAddObject( a1, @"Juliet" )
|
|
MutableArrayAddObject( a1, @"Golf" )
|
|
MutableArrayAddObject( a1, @"India" )
|
|
for i = 0 to len(a1) - 1
|
|
print a1[i],
|
|
next
|
|
print
|
|
|
|
MutableArrayReplaceObjectAtIndex( a1, @"Foxtrot", 0 )
|
|
MutableArrayReplaceObjectAtIndex( a1, @"Hotel", 2 )
|
|
for i = 0 to len(a1) - 1
|
|
print a1[i],
|
|
next
|
|
|
|
print : print
|
|
end fn
|
|
|
|
void local fn FB_MDA
|
|
long i
|
|
|
|
text ,, fn ColorGray
|
|
print @"// FB MDA - mutable, dynamic, multi-dimensional"
|
|
text
|
|
|
|
mda_add = @"Alpha"
|
|
mda_add = @"Romeo"
|
|
mda_add = @"Mike"
|
|
|
|
for i = 0 to mda_count - 1
|
|
print mda(i),
|
|
next
|
|
|
|
print
|
|
|
|
mda_swap(0),(2)
|
|
mda(1) = @"Delta"
|
|
|
|
for i = 0 to mda_count - 1
|
|
print mda(i),
|
|
next
|
|
end fn
|
|
|
|
fn CType
|
|
fn CTypeDynamic
|
|
fn CoreFoundationImmutable
|
|
fn CoreFoundationMutableFixedLength
|
|
fn CoreFoundationMutableDynamic
|
|
fn FB_MDA
|
|
|
|
HandleEvents
|