How to declare a dynamic Array
Author Message
How to declare a dynamic Array

I got error message when I declare a dynamic array :

Local A[b,c,d]
Local i, j, k

For i:=1 to 10
For j:=1 to 15
For k:=1 to 20
A[i,j,k] := 0
Next
Next
Next

- Ted

Sat, 06 Dec 1997 03:00:00 GMT
How to declare a dynamic Array

Quote:

> I got error message when I declare a dynamic array :

> Local A[b,c,d]
> Local i, j, k

> For i:=1 to 10
>    For j:=1 to 15
>       For k:=1 to 20
>          A[i,j,k] := 0
>       Next
>    Next
> Next

Ted,

What you've declared is not a dynamic array. You've preset it to fixed dimensions.

You don't say what the values of b, c and d are. For the code you describe to work
These variables must be declared and assigned values of 10, 15 and 20 respectively.

What was the error you got?

--
---------------------------------------------------------------------------

| "Pay the man and damn his impudence!" - Prince George, BlackAdder.      |
---------------------------------------------------------------------------

Sat, 06 Dec 1997 03:00:00 GMT
How to declare a dynamic Array
And so spake Ted Yeung:
: I got error message when I declare a dynamic array :
: Local A[b,c,d]
: Local i, j, k
: For i:=1 to 10
:    For j:=1 to 15
:       For k:=1 to 20
:          A[i,j,k] := 0
:       Next
:    Next
: Next

You neglected to say what the error was, or if this is in a function.  I will
assume it is, and that it is passed b, c, and d.  Your For statements should
use the passed dimension variables instead of fixed values:

Local A[b,c,d]
Local i, j, k
For i:=1 to b
For j:=1 to c
For k:=1 to d
A[i,j,k] := 0
Next
Next
Next

Better yet, replace all that with this:

Local A[b,c,d]
aeval(A, {|barray| aeval(barray, {|carray| afill(carray, 0)})})

-Dave

--

\_\_Database Guy\_\_\_\_\_\_\_\_\_\_\_NASA Langley Research Center\_\_/_/
\_\_I-NET, Inc. \_\_\_\_\_\_\_\_\_\_\_\_\_\_Hampton, {*filter*}ia, USA\_\_/
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_
_/_/Ut Prosim _/_/_/_/_/_/_/_/_/_/_/_/_/_/_/The truth is out there_/_/_\_
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_\_\_
Opinions expressed herein are a mixture of hearsay and advertising sound
bites.  As such, they may or may not be Official expressions of anything.

Sun, 07 Dec 1997 03:00:00 GMT
How to declare a dynamic Array
+-
| I got error message when I declare a dynamic array :
|
| Local A[b,c,d]
| Local i, j, k
|
| For i:=1 to 10
|    For j:=1 to 15
|       For k:=1 to 20
|          A[i,j,k] := 0
|       Next
|    Next
| Next
+-[TY=>All]

What was the error?

Was it at compile time or run time?

If it was at run time, where did it fall over?

If b,c or d are smaller than the fixed 10, 15 and 20 that you have, then
you probably have a bounds problem.

response.

DrDebug

MrTag 1.20 : Only losers don't use MrDebug

##MMR 2.61..  !link TY  6-20-95 00:09

+-----------------------------+------------------------------------------+

| The Dark Knight Returns BBS |      BBS:      Dark Knight: 01480 471465 |
| The Home of MrDebug         |      Fax:                   01480 471465 |
|  (THE CA-Clipper de{*filter*})  |      Tel:                   01480 403104 |
+-----------------------------+------------------------------------------+

Sun, 07 Dec 1997 03:00:00 GMT

 Page 1 of 1 [ 4 post ]

Relevant Pages