Hi Bruce,
Does the compiler support passing a pointer to an integer array?
such as:
#define ARRAYSIZE 10
dim array(ARRAYSIZE) as integer
FUNCTION findSum(BYREF array)
dim sum as integer
dim i as integer
for i=0 to ARRAYSIZE
sum = sum + array(i)
next
return (sum)
END FUNCTION
main:
dim i as integer
for i=0 to ARRAYSIZE
array(i) = i
next i
print findSum(array)
end
BYREF arrays
-
YahooArchive
- Posts: 1462
- Joined: Fri Oct 19, 2012 5:11 am
Re: BYREF arrays
No the compiler only supports BYREF passing of a STRING or BYTE array at
present.
But you can accomplish the same thing by passing ADDRESSOF array, and then use
pointers to read or write elements
sub x(addr, offset)
dim x
x = *(addr + (offset<<2))
*(addr + (offset<<2)) = x
end sub
main:
dim a(20)
x(addressof a, 3)
present.
But you can accomplish the same thing by passing ADDRESSOF array, and then use
pointers to read or write elements
sub x(addr, offset)
dim x
x = *(addr + (offset<<2))
*(addr + (offset<<2)) = x
end sub
main:
dim a(20)
x(addressof a, 3)