Array as a parameter? - Printable Version +- Qbasicnews.com (http://qbasicnews.com/newforum) +-- Forum: Qbasic "like" compilers/interpreters (http://qbasicnews.com/newforum/forum-5.html) +--- Forum: FB Discussion & Programming Help (http://qbasicnews.com/newforum/forum-15.html) +--- Thread: Array as a parameter? (/thread-9246.html) |
Array as a parameter? - Torahteen - 05-02-2006 I've done this before, but it's not working this time. Here is my error: Code: game.bi(15) : error 57: Illegal specification, at parameter 1: list Array as a parameter? - stylin - 05-02-2006 Are you sure PointType has been declared before this function declaration? Array as a parameter? - Torahteen - 05-02-2006 Woops :oops:. Now that i've fixed that... Are you not allowed to DIMension an array (more specifically a dynamic array) inside a SUB or Function? Array as a parameter? - stylin - 05-02-2006 You sure can: Code: sub foo(dynamicSize as integer) staticSize must be a compile-time constant, of course (const, enum or literal). Array as a parameter? - Anonymous - 05-02-2006 since .16, you can also do this Code: sub foo() before you could not specify "dimensionless" arrays inside of sub/funcs Array as a parameter? - Antoni Gual - 05-02-2006 Don't forget the arrays DIMed in subs/functions are created on the stack, and the stack is 1Mb by default. If you need a bigger array either you make it shared, increase the stack size or use direct memory allocation. Array as a parameter? - wallace - 05-03-2006 You can also make a memory block act like an array. Code: Declare Function newInt(size as uinteger) as integer ptr Ah, dynamic allocation Array as a parameter? - stylin - 05-03-2006 Be careful using literals for datatype size like that. You should always prefer sizeof or len. I prefer sizeof myself, simply because it seems more compile-time to me, as len is also a run-time function. But they both give compile-time results for var and datatype sizes. |