 |
Microsoft Knowledge Base Article
This article contents is Microsoft Copyrighted material.
©2005-©2007 Microsoft Corporation. All rights reserved. Terms
of Use |
Trademarks
Article ID: 34279 - Last Review: November 21, 2006 - Revision: 1.2 Cannot Pass More Than 21 Dynamic Array Elements to SubprogramThis article was previously published under Q34279
Passing more than 20 individual elements of a dynamic array to a
subprogram or function procedure will produce the compiler error "Too
many arguments in function call." This limitation occurs for all types
of dynamic arrays. Either the whole array should be passed, or each
item should be copied to a temporary variable and then passed to the
subprogram or function.
This limitation occurs because of special handling done for dynamic
arrays. When a subprogram is called, there is no way of ensuring that
the dynamic array will not move. Therefore, when individual array
elements are passed by reference, each is copied into a temporary
location. These temporary locations are passed to the routine and then
reassigned to the array when the routine is exited. There is a limit
of 20 temporary locations.
The following is a complete code example:
DECLARE SUB test2 (a1!, a2!, a3!, a4!, a5!, a6!, a7!, a8!, a9!,_
a10!, a11!, a12!, a13!, a14!, a15!, a16!, a17!,_
a18!, a19!, a20!, a21!)
x = 30
DIM a(x)
CALL test2(a(1), a(2), a(3), a(4), a(5), a(6), a(7), a(8), a(9),_
a(10), a(11), a(12), a(13), a(14), a(15), a(16), a(17),_
a(18), a(19), a(20), a(21))
END
SUB test2 (a1!, a2!, a3!, a4!, a5!, a6!, a7!, a8!, a9!, a10!, a11!,_
a12!, a13!, a14!, a15!, a16!, a17!, a18!, a19!, a20!, a21!)
PRINT "hello"
END SUB
The following is the compiler output:
Microsoft (R) QuickBasic Compiler Version 4.00b
Copyright (C) Microsoft Corp. 1982-1988. All rights reserved.
0053 0006 ...a(18),a(19),a(20),a(21))
^ Too many arguments in function call
43059 Bytes Available
37660 Bytes Free
0 Warning Error(s)
1 Severe Error(s)
APPLIES TO- Microsoft QuickBasic 4.0
- Microsoft QuickBASIC 4.0b
- Microsoft QuickBasic 4.5 for MS-DOS
- Microsoft BASIC Compiler 6.0
- Microsoft BASIC Compiler 6.0b
- Microsoft BASIC Professional Development System 7.0
Retired KB Content DisclaimerThis article was written about products for which Microsoft no longer offers support. Therefore, this article is offered "as is" and will no longer be updated.
Community Feedback System
Very often, it takes hours to solve a problem. Very often, you've looked high
and low, and have tried a lot of solutions. When you finally found it, chances
are, it was because someone else helped you. Here's your chance to give back.
Use our community feedback tool to let others know what worked for you and what
didn't.
Please also understand that the community feedback system is not warranted to be
correct, it's simply a system that we've built to let people try and help each
other. If something in a feedback response doesn't make sense to you, or you're
not comfortable making changes that the feedback talks about (like registry
edits), please consult a professional.
Thank you for using kbAlertz.com Feedback System.
-- Scott Cate
Be the first to leave feedback, to help others about this knowledge base
article.
(Optional) Name
(Optional)
Public URL Or Email
Comments
No
HTML -- Text Only Please
|
 |