Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
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
New to QB64pe? Visit the QB64 tutorial to get started.
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: 1 Guest(s)