• Welcome to Powerbasic Museum 2020-B.
 

News:

Forum in repository mode. No new members allowed.

Main Menu

in what situation, "DIM" is required?

Started by Eduardo Jorge, June 17, 2018, 04:01:56 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Eduardo Jorge

Hello

Dim int x
int x
one that I realized was of array's when it defines values, but it accuses error of ","


  DIM int arr(32)={
00, 01, 02, 03, 04, 05, 06, 07, _
08, 09, 10, 11, 12, 13, 14, 15, _
16, 17, 18, 19, 20, 21, 22, 23, _
24, 25, 26, 27, 28, 29, 30, 31
}

I had problems in other situations, but I did not pay attention, and it was solved by putting Dim

Charles Pegge

Hi Eduardo,

When you omit dim, you will need to uses square brackets when specifying array size. This is required to distinguish between C-style variable declarations and C-style function declarations/headers.

Eduardo Jorge

#2
thanks for the answers Charles
for reasons of understanding and standardization I will use dim in all statements

just to make it clear
long arr [32] = {00, 01, 02, 03, 04, 05, 06, 07}
DIM long arr (32) = {00, 01, 02, 03, 04, 05, 06, 07}

but why is that so no error?
int arr ( 8 )

Charles Pegge

Yes, those first 2 examples are correct

The last will throw an error when you try to use it :)

Eduardo Jorge

as I had proposed in the other forum would be good a sub forum as temporary manual,
something to be edited gradually, as the questions and solutions appear

has many O2 details that need to be clear,
some of them gave me dozens of attempts without knowing where I was going wrong

the ARRAYS will probably be the most visited