# Appending text

**URL:** <https://techcommunity.softwareag.com/t/appending-text/75480>\
**Category:** Forum\
**Tags:** Adabas-Natural, Natural, Natural-on-Mainframes\
**Created:** [October 5, 2007, 2:37pm UTC](https://techcommunity.softwareag.com/t/appending-text/75480 "2007-10-05T14:37:49Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![sriramp](https://avatars.discourse-cdn.com/v4/letter/s/bc79bd/32.png) [@sriramp](https://techcommunity.softwareag.com/u/sriramp)\
**Post date:** [October 5, 2007, 2:37pm UTC](https://techcommunity.softwareag.com/t/appending-text/75480/1 "2007-10-05T14:37:49Z")

</div>

Hi,

Is it possible to append a text to another text in Natural.

Suppose,

#A=“ABC”  
I want the numbers 1 to 9 also to be alongwith the variable #A.

I will be doin the appending of the numbers in a loop each number separated by a comma.

I want the result to be “ABC,1,2,3,4,5,6,7,8,9”

---

<div class="post-metadata">

**Author:** ![sriramp](https://avatars.discourse-cdn.com/v4/letter/s/bc79bd/32.png) [@sriramp](https://techcommunity.softwareag.com/u/sriramp)\
**Post date:** [October 5, 2007, 3:49pm UTC](https://techcommunity.softwareag.com/t/appending-text/75480/2 "2007-10-05T15:49:38Z")

</div>

Folks,

I got the answer myself…It is as follows,

MOVE “ABC” to #TXTA

FOR #I 1 TO 9  
COMPRESS #TXTA #I INTO #TXTA WITH ALL DELIMITERS ‘,’  
END-FOR

Thanks,

---

<div class="post-metadata">

**Author:** ![Steve\_Robinson](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/steve_robinson/32/107_2.png) [@Steve\_Robinson](https://techcommunity.softwareag.com/u/Steve_Robinson)\
**Post date:** [October 5, 2007, 4:04pm UTC](https://techcommunity.softwareag.com/t/appending-text/75480/3 "2007-10-05T16:04:41Z")

</div>

I hope you are not intending to put this code into production anywhere.

Instead of your code, try:

MOVE ‘ABC,1,2,3,4,5,6,7,8,9’ TO #TXTA

Assuming that the numbers you want to add are not really 1…9 but numbers in an array, try:

COMPRESS #TXTA #ARRAY (\*) INTO #TXTA WITH DELIMITER ‘,’

You might want (as you had above), ALL DELIMITERS, if #ARRAY is alpha. Then a blank entry in #ARRAY would produce something like 1,2,4 etc

This would not happen if #ARRAY was numeric. COMPRESS with a zero value would result in a string such as 1,2,0,4 etc

Finally, two points. First, using the FOR loop as you showed above is about as inefficient a way to do this as exists in Natural (okay, i guess if you really tried you could do something like):

```
            FOR #I = 1 to 9
            COMPRESS #TXTA #I INTO #TXTA LEAVING NO SPACE
            COMPRESS #TXTA ',' INTO #TXTA LEAVING NO SPACE
            END-FOR

```

Next, please get a Natural class and do not try to learn Natural by yourself. You will end up writing horrible code.

steve

---

<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, 2:48pm UTC](https://techcommunity.softwareag.com/t/appending-text/75480/4 "2021-04-02T14:48:48Z")

</div>


