Oxygen Basic

Programming => Problems & Solutions => Topic started by: chrisc on March 20, 2018, 07:49:33 PM

Title: Any example on arrays
Post by: chrisc on March 20, 2018, 07:49:33 PM
Hello

Is there any example on arrays?

in PB, we define array as

Code: [Select]
DIM k(1 TO 8) AS STRING

how to do in O2?
Title: Re: Any example on arrays
Post by: Charles Pegge on March 20, 2018, 09:27:39 PM
Hi Chris,

The default indexbase is 1. So:

Code: [Select]
dim k(8) as string
dim as string k(8)
dim string k(8)
string k[8] 'C style

You can change the indexbase at any time. It alters your frame of reference:
indexbase 0
indexbase 1
Title: Re: Any example on arrays
Post by: chrisc on March 21, 2018, 04:17:00 AM
Thanxx Charles

can we do something like :  starting from elem 5 to 8 ?

Code: [Select]
dim k(5:8) as string

instead of

Code: [Select]
indexbase 5
dim k(8) as string


Title: Re: Any example on arrays
Post by: Charles Pegge on March 21, 2018, 05:33:42 AM
Not at present, Chris. o2 arrays are primitive. Dim string k[8] and ignore elements 1 to 4