# Array in Natural

**URL:** <https://techcommunity.softwareag.com/t/array-in-natural/170996>\
**Category:** Forum\
**Tags:** Adabas-Natural, Natural, Natural-News-and-General-Topics\
**Created:** [May 7, 2013, 1:52pm UTC](https://techcommunity.softwareag.com/t/array-in-natural/170996 "2013-05-07T13:52:07Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Joseph\_Tharakan](https://avatars.discourse-cdn.com/v4/letter/j/7feea3/32.png) [@Joseph\_Tharakan](https://techcommunity.softwareag.com/u/Joseph_Tharakan)\
**Post date:** [May 7, 2013, 1:52pm UTC](https://techcommunity.softwareag.com/t/array-in-natural/170996/1 "2013-05-07T13:52:07Z")

</div>

I have seen only the use of /1:10 in defining an array. Is the 1 in it having any specific meaning? Why it is used? Does it have any implied meaning? Can we change that to any other number and will it change its features? Please help me out 🙂 🙂

---

<div class="post-metadata">

**Author:** ![Ralph\_Zbrog](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/ralph_zbrog/32/78_2.png) [@Ralph\_Zbrog](https://techcommunity.softwareag.com/u/Ralph_Zbrog)\
**Post date:** [May 7, 2013, 3:32pm UTC](https://techcommunity.softwareag.com/t/array-in-natural/170996/2 "2013-05-07T15:32:51Z")

</div>

The size of an array dimension is defined by two integers, a start and an end, such as #A (1:10). Natural will provide a start value of 1 by default, so #A (10) is equivalent.

Depending on your requirements, other start values may be used. (3:5) and (6:8) both allocate 3 occurrences. These examples are more common when using Adabas Periodic Groups.

Even negative integers and zero may be used.

```auto
(-4:-2) 3 occurrences
(-5:1) 7 occurrences
(0:10) 11 occurrences
```

---

<div class="post-metadata">

**Author:** ![Nikolay\_Kuhta](https://avatars.discourse-cdn.com/v4/letter/n/35a633/32.png) [@Nikolay\_Kuhta](https://techcommunity.softwareag.com/u/Nikolay_Kuhta)\
**Post date:** [May 7, 2013, 3:35pm UTC](https://techcommunity.softwareag.com/t/array-in-natural/170996/3 "2013-05-07T15:35:18Z")

</div>

Hi Joseph,

Well, I suspect you have some advanced skills in Java where the first array`s index is 0 🙂  
Meanwhile, Natural also can handle it; you may take a look at the following very simple code which shows you some “similar” behavior in Natural. My point: you may even use negative indexes, but do you really need them? 🙂

Best regards.  
0010 DEFINE DATA LOCAL  
0020 1 #ARRAY (A3/-5:\*)  
0030 1 #DIMEN (I4)  
0040 1 #INCREASE (I4) CONST \<10\>  
0050 1 #TWENTY (I4) CONST \<20\>  
0060 1 #ITEM (A3) CONST \<‘abc’\>  
0070 1 #I (I2)  
0080 END-DEFINE  
0090 #DIMEN := 5  
0100 EXPAND ARRAY #ARRAY TO (-5 : #DIMEN)  
0110 FOR #I = -5 TO #TWENTY  
0120 IF #I \> #DIMEN  
0130 ADD #INCREASE TO #DIMEN  
0140 EXPAND ARRAY #ARRAY TO (-5:#DIMEN)  
0150 END-IF  
0160 #ARRAY (#I) := #ITEM  
0170 END-FOR  
0180 FOR #I = -5 TO #DIMEN  
0190 DISPLAY #ARRAY (#I) #I  
0200 END-FOR  
0210 END

---

<div class="post-metadata">

**Author:** ![Joseph\_Tharakan](https://avatars.discourse-cdn.com/v4/letter/j/7feea3/32.png) [@Joseph\_Tharakan](https://techcommunity.softwareag.com/u/Joseph_Tharakan)\
**Post date:** [May 7, 2013, 3:41pm UTC](https://techcommunity.softwareag.com/t/array-in-natural/170996/4 "2013-05-07T15:41:04Z")

</div>

Actually what is the need for these if 3:5 and 4:6 are actually containing 2 occurences

---

<div class="post-metadata">

**Author:** ![Ralph\_Zbrog](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/ralph_zbrog/32/78_2.png) [@Ralph\_Zbrog](https://techcommunity.softwareag.com/u/Ralph_Zbrog)\
**Post date:** [May 7, 2013, 4:42pm UTC](https://techcommunity.softwareag.com/t/array-in-natural/170996/5 "2013-05-07T16:42:13Z")

</div>

Let’s take a financial application for example. We retrieve the 2nd quarter values from an Adabas file.

```auto
2 MONTHLY (4:6)
```

These are values for April, May, and June. We need temporary storage.

```auto
1 #MTH (P7.2/1:3)
```

But coding would be much simpler if we could use the same index values for both arrays, so

```auto
1 #MTH (P7.2/4:6)
```

---

<div class="post-metadata">

**Author:** ![Joseph\_Tharakan](https://avatars.discourse-cdn.com/v4/letter/j/7feea3/32.png) [@Joseph\_Tharakan](https://techcommunity.softwareag.com/u/Joseph_Tharakan)\
**Post date:** [May 8, 2013, 8:16am UTC](https://techcommunity.softwareag.com/t/array-in-natural/170996/6 "2013-05-08T08:16:49Z")

</div>

Ralph and Nicolay, Thanks for the response and making me clear of the actual use of it

---

<div class="post-metadata">

**Author:** ![Mick\_Fitzpatrick](https://avatars.discourse-cdn.com/v4/letter/m/a698b9/32.png) [@Mick\_Fitzpatrick](https://techcommunity.softwareag.com/u/Mick_Fitzpatrick)\
**Post date:** [May 8, 2013, 3:37pm UTC](https://techcommunity.softwareag.com/t/array-in-natural/170996/7 "2013-05-08T15:37:36Z")

</div>

> [@Ralph Zbrog](#):
>
> Even negative integers and zero may be used.
> 
> ```auto
> (-4:-2) 3 occurrences
> (-5:1) 7 occurrences
> (0:10) 11 occurrences
> ```

Just to address the negative indices part of the answer as it seems to be the only part not given an exaple reason for using them.

I can recall only one situation where I defined an array with negative indices and that was i an application where it help to visualize the array(s) in terms of and X and Y axis and where I needed to know which quadrant a particular array occurrence/point/coordinate was.

I’ve also ofter used occurrence zero as a total line entry where it summed the occurrences of the other entries in the array.

That said; both of these scenarios could also have been achieved without using negative indices or zero. It was just easier to keep straight in my head as I coded.

---

<div class="post-metadata">

**Author:** ![Joseph\_Tharakan](https://avatars.discourse-cdn.com/v4/letter/j/7feea3/32.png) [@Joseph\_Tharakan](https://techcommunity.softwareag.com/u/Joseph_Tharakan)\
**Post date:** [May 8, 2013, 3:46pm UTC](https://techcommunity.softwareag.com/t/array-in-natural/170996/8 "2013-05-08T15:46:34Z")

</div>

Thanks Mick. I didn’t expect this much detailed help here. I am new to Natural and Adabas. I am on my training period in which I am not having a good resource to clarify my doubts. Also I am not aware of the advantages of studying these. I am learning as the buisness needs more resources

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/techcommunity/original/3X/c/d/cd19967bb605d28a72d77eb83a1cae22f3df2eb8.svg) [@system](https://techcommunity.softwareag.com/u/system)\
**Post date:** [April 2, 2021, 3:28pm UTC](https://techcommunity.softwareag.com/t/array-in-natural/170996/9 "2021-04-02T15:28:46Z")

</div>

Closed on April 2, 2021, 3:28pm UTC


