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

Re: Using dim for arrays


On 8/25/25 13:29, Brian G wrote:
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

I have updated the entry to look like this, this is just the text of course.

DIM
This keyword is used for declaring local variables.
All DIM declarations must be in the FUNCTION or SUB before the first use of that variable. Variables and arrays no longer need to be defined before the first executable command.
Examples
DIM fTimeDiff2 AS Float
DIM iTest AS Integer
DIM iK AS new Integer[9] ' ik[0] to ik[8]
DIM shX AS new Short[3,3]
DIM date1 AS Date

iTest = 8
See also
Local Variable Declaration
Naming Conventions

--
~~~~ Brian

Attachment: OpenPGP_0x78BFB26402F48419.asc
Description: OpenPGP public key

Attachment: OpenPGP_signature.asc
Description: OpenPGP digital signature


Follow-Ups:
Re: Using dim for arraysBenoît Minisini <benoit.minisini@xxxxxxxxxxxxxxxx>
References:
Using dim for arraysBrian G <brian@xxxxxxxxxxxxxxxx>
Re: Using dim for arraysBrian G <brian@xxxxxxxxxxxxxxxx>