# Arrays in INDEPENDENT variables

**URL:** <https://techcommunity.softwareag.com/t/arrays-in-independent-variables/234766>\
**Category:** Forum\
**Tags:** Adabas-Natural, Adabas, Natural\
**Created:** [October 19, 2020, 3:56pm UTC](https://techcommunity.softwareag.com/t/arrays-in-independent-variables/234766 "2020-10-19T15:56:58Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ricardo\_Gomez1](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/ricardo_gomez1/32/7963_2.png) [@Ricardo\_Gomez1](https://techcommunity.softwareag.com/u/Ricardo_Gomez1)\
**Post date:** [October 19, 2020, 3:56pm UTC](https://techcommunity.softwareag.com/t/arrays-in-independent-variables/234766/1 "2020-10-19T15:56:58Z")

</div>

Hello, how can I use arrays in INDEPENDENT variables.

01 +W-CAMPOARR (A40/1:4)  
…  
WRITE &W-CAMPOARR(1)

Index entry incorrectly specified for field.

Thank you,  
Greetings

---

<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:** [October 19, 2020, 5:03pm UTC](https://techcommunity.softwareag.com/t/arrays-in-independent-variables/234766/2 "2020-10-19T17:03:37Z")

</div>

The ampersand (&) is used only to designate dynamic text. Normally you would code

```auto
DEFINE DATA INDEPENDENT
1 +W-CAMPOARR (A40/1:4)
END-DEFINE
WRITE '=' +W-CAMPOARR (1)
END

```

---

<div class="post-metadata">

**Author:** ![Ricardo\_Gomez1](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/ricardo_gomez1/32/7963_2.png) [@Ricardo\_Gomez1](https://techcommunity.softwareag.com/u/Ricardo_Gomez1)\
**Post date:** [October 19, 2020, 5:20pm UTC](https://techcommunity.softwareag.com/t/arrays-in-independent-variables/234766/3 "2020-10-19T17:20:40Z")

</div>

> [@Ricardo\_Gomez1](#):
>
> WRIT

thanks.  
but I need to use the value & and not the +

NAT0280 Index entry incorrectly specified for field.  
WRITE &W-CAMPOARR (1)

currently:  
01 +W-CAMPO1 (A40)  
01 +W-CAMPO2 (A40)  
01 +W-CAMPO3 (A40)  
01 +W-CAMPO4 (A40)

but i require:  
01 +W-CAMPOARR (A40/1:4)

actually works with WRITE & W-CAMPOARR but I only get the first position of the array

Greetings

---

<div class="post-metadata">

**Author:** ![Jerome\_LeBlanc](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/jerome_leblanc/32/111_2.png) [@Jerome\_LeBlanc](https://techcommunity.softwareag.com/u/Jerome_LeBlanc)\
**Post date:** [October 19, 2020, 6:42pm UTC](https://techcommunity.softwareag.com/t/arrays-in-independent-variables/234766/4 "2020-10-19T18:42:34Z")

</div>

Ralph is (of course) correct. You do not want & in your case. &W-CAMPOARR is not a valid variable.

```auto
DEFINE DATA INDEPENDENT                      
1 +W-CAMPOARR (A4/1:4) INIT <'a','b','c','d'>
END-DEFINE                                   
WRITE '=' +W-CAMPOARR (*)                    
WRITE '=' +W-CAMPOARR (1)                    
WRITE '=' +W-CAMPOARR (2)                    
WRITE '=' +W-CAMPOARR (3)                    
WRITE '=' +W-CAMPOARR (4)                    
END

```

Output:

```auto
 +W-CAMPOARR: a b c d  
 +W-CAMPOARR: a                  
 +W-CAMPOARR: b                 
 +W-CAMPOARR: c                  
 +W-CAMPOARR: d                 

```

However, independent variables are tricky. If you have already defined them in your session, you cannot change them until you restart your session or using the RELEASE VARIABLES statement.

---

<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:** [October 19, 2020, 8:33pm UTC](https://techcommunity.softwareag.com/t/arrays-in-independent-variables/234766/5 "2020-10-19T20:33:14Z")

</div>

OP said

> but I need to use the value & and not the +

If this is indeed true, then I would quote the Statements manual, Run statement, Dynamic Source:

> A global variable with index must not be used within a program that is invoked via a `RUN` statement.

You are not allowed to change the +W-CAMPOx scalars to an array.

---

<div class="post-metadata">

**Author:** ![Ricardo\_Gomez1](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/ricardo_gomez1/32/7963_2.png) [@Ricardo\_Gomez1](https://techcommunity.softwareag.com/u/Ricardo_Gomez1)\
**Post date:** [October 19, 2020, 9:46pm UTC](https://techcommunity.softwareag.com/t/arrays-in-independent-variables/234766/6 "2020-10-19T21:46:17Z")

</div>

> [@Ralph\_Zbrog](#):
>
> A global variable with index must not be used within a program that is invoked via a `RUN` statement.

Thanks,  
Greetings

---

<div class="post-metadata">

**Author:** ![Ricardo\_Gomez1](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/ricardo_gomez1/32/7963_2.png) [@Ricardo\_Gomez1](https://techcommunity.softwareag.com/u/Ricardo_Gomez1)\
**Post date:** [October 19, 2020, 9:46pm UTC](https://techcommunity.softwareag.com/t/arrays-in-independent-variables/234766/7 "2020-10-19T21:46:32Z")

</div>

thanks,  
Greetings

---

<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:45pm UTC](https://techcommunity.softwareag.com/t/arrays-in-independent-variables/234766/8 "2021-04-02T15:45:17Z")

</div>


