AboutAlex Barry Expertise I have been a qbasic programmer since 2000, creating games, minor libraries and various small programs. I have experience using interrupts, graphics, file input/output, the mouse cursor, and using libraries. I have also learned FreeBASIC, c/c++, python, php and html.
I do not claim to be an absolute authority in any language, but I don't mind looking things up and learning with you.
Experience Hobby programming since 2000
I no longer belong to any community programming groups, but do have knowledge of *basic dialects and C/C++
Question Is it possible to pass array as an argument/parameter in qbasic function? if yes, please let me know. Thanks. With Regards,
Ranj
Answer Hi, Ranj,
Yes, to pass an array to a SUB/FUNCTION, this is what you'd need to do:
DECLARE SUB PassArray( yourArray%() )
DIM anArray%(1 TO 10)
DIM i AS INTEGER
RANDOMIZE TIMER
FOR i = 1 TO 10
anArray%( i ) = rnd * 100
NEXT i
' If this causes an error, it may be that you just use
' PassArray( anArray% )
' I think later versions let you do the above line, but
' I'm not completely sure on that one.
PassArray( anArray%() )
SUB PassArray( yourArray%() )
DIM min AS INTEGER
DIM max AS INTEGER
DIM i AS INTEGER
min = LBOUND( yourArray% )
max = UBOUND( yourArray% )
FOR i = min TO max
PRINT "Array Index:"; i; " = "; yourArray%( i )
NEXT i
END SUB