Author Topic: Any example on arrays  (Read 1022 times)

0 Members and 1 Guest are viewing this topic.

chrisc

  • Guest
Any example on arrays
« 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?

Charles Pegge

  • Guest
Re: Any example on arrays
« Reply #1 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

chrisc

  • Guest
Re: Any example on arrays
« Reply #2 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



Charles Pegge

  • Guest
Re: Any example on arrays
« Reply #3 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