array assigned in SUBs
#3
(06-11-2023, 03:10 AM)sivacc Wrote: ReDim and assign an array within a SUB and pass through the SUB's parameters 
.......
getarray z%()
print ubound(z%), z%(5)
end
SUB getarray( x() as integer)
n%= 25
ReDim as ineger x(0 to n%-1)
for p%= 0 to  n%-1
x%(p%)= p%*p%
next
end sub
Here is what I believe you are looking for:

Code: (Select All)
REDIM AS INTEGER x(0)

getarray x()
PRINT UBOUND(x), x(5)
END


SUB getarray (x() AS INTEGER)
    n% = 25
    REDIM AS INTEGER x(0 TO n% - 1)
    FOR p% = 0 TO n% - 1
        x(p%) = p% * p%
    NEXT
END SUB
Software and cathedrals are much the same — first we build them, then we pray.
QB64 Tutorial
Reply


Messages In This Thread
array assigned in SUBs - by sivacc - 06-11-2023, 03:10 AM
RE: array assigned in SUBs - by SMcNeill - 06-11-2023, 03:41 AM
RE: array assigned in SUBs - by TerryRitchie - 06-11-2023, 03:43 AM
RE: array assigned in SUBs - by sivacc - 06-11-2023, 08:32 AM
RE: array assigned in SUBs - by TerryRitchie - 06-11-2023, 03:24 PM
RE: array assigned in SUBs - by sivacc - 06-12-2023, 06:41 AM



Users browsing this thread: 3 Guest(s)