[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Using dim for arrays


On 8/25/25 08:27, Brian G wrote:

Why is

  Public a[7000] as integer
  Private a[7000] as integer
  private a as new integer[7000]

all work

but in a function/sub only

dim a as new integer[7000]

works

when help system says that

dim a[7000] as integer

is supposed to be valid but in fact returns the error

embedded arrays are invalid here

Help system says:


  DIM

This keyword is used for declaring local variables. All DIM declarations must be in theFUNCTION <https://gambaswiki.org/wiki/lang/function>orSUB <https://gambaswiki.org/wiki/lang/sub>before the first executable command.


      Examples

*DIM* fTimeDiff2 *AS* *Float*
*DIM* iTest *AS* *Integer*
*DIM* iK*[*9*]* *AS* *Integer* ' ik[0] to ik[8]
*DIM* shX*[*3*,*3*]* *AS* *Short*
*DIM* date1 *AS* *Date*

iTest *=* 8


      See also

  * Local Variable Declaration
    <https://gambaswiki.org/wiki/lang/localdecl>
  * Naming Conventions <https://gambaswiki.org/wiki/doc/naming>


I am thinking this may need a rewrite, as the before anything else no longer applies, what is the correct way to declare a static array?

--
~~~~ Brian

Attachment: OpenPGP_0x78BFB26402F48419.asc
Description: OpenPGP public key

Attachment: OpenPGP_signature.asc
Description: OpenPGP digital signature


Follow-Ups:
Re: Using dim for arraysBrian G <brian@xxxxxxxxxxxxxxxx>
References:
Using dim for arraysBrian G <brian@xxxxxxxxxxxxxxxx>