Powerbasic Museum 2020-B

IT-Consultant: Charles Pegge => OxygenBasic => Topic started by: Eduardo Jorge on June 17, 2018, 04:01:56 PM

Title: in what situation, "DIM" is required?
Post by: Eduardo Jorge on June 17, 2018, 04:01:56 PM
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
Title: Re: in what situation, "DIM" is required?
Post by: Charles Pegge on June 17, 2018, 04:16:07 PM
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.
Title: Re: in what situation, "DIM" is required?
Post by: Eduardo Jorge on June 17, 2018, 04:24:09 PM
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 )
Title: Re: in what situation, "DIM" is required?
Post by: Charles Pegge on June 17, 2018, 06:02:50 PM
Yes, those first 2 examples are correct

The last will throw an error when you try to use it :)
Title: Re: in what situation, "DIM" is required?
Post by: Eduardo Jorge on June 17, 2018, 06:12:57 PM
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