# Natural Statements - MASK or IS

**URL:** <https://techcommunity.softwareag.com/t/natural-statements-mask-or-is/202683>\
**Category:** Forum\
**Tags:** Adabas-Natural, Natural, Natural-on-Mainframes\
**Created:** [February 4, 2019, 2:00pm UTC](https://techcommunity.softwareag.com/t/natural-statements-mask-or-is/202683 "2019-02-04T14:00:00Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Prakash\_Parandhaman](https://avatars.discourse-cdn.com/v4/letter/p/eb8c5e/32.png) [@Prakash\_Parandhaman](https://techcommunity.softwareag.com/u/Prakash_Parandhaman)\
**Post date:** [February 4, 2019, 2:00pm UTC](https://techcommunity.softwareag.com/t/natural-statements-mask-or-is/202683/1 "2019-02-04T14:00:00Z")

</div>

Hi,

I am trying to find a variable length by using MASK parameter, but its not working.

eg:  
Local  
01 #INPUT (a8)  
end-define

IF #INPUT EQ MASK(AAAAAAAA)  
write stmts  
else  
write stmts  
END-IF

The #INPUT value may have 5 or 8 byte of alpha numeric data. If its 5 byte of data, then it should fall on else part. But its not happening. Kindly advice

---

<div class="post-metadata">

**Author:** ![Prakash\_Parandhaman](https://avatars.discourse-cdn.com/v4/letter/p/eb8c5e/32.png) [@Prakash\_Parandhaman](https://techcommunity.softwareag.com/u/Prakash_Parandhaman)\
**Post date:** [February 4, 2019, 2:02pm UTC](https://techcommunity.softwareag.com/t/natural-statements-mask-or-is/202683/2 "2019-02-04T14:02:26Z")

</div>

#INPUT (a 8)

---

<div class="post-metadata">

**Author:** ![Prakash\_Parandhaman](https://avatars.discourse-cdn.com/v4/letter/p/eb8c5e/32.png) [@Prakash\_Parandhaman](https://techcommunity.softwareag.com/u/Prakash_Parandhaman)\
**Post date:** [February 4, 2019, 2:04pm UTC](https://techcommunity.softwareag.com/t/natural-statements-mask-or-is/202683/3 "2019-02-04T14:04:11Z")

</div>

#INPUT (a 8 )

---

<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:** [February 4, 2019, 6:26pm UTC](https://techcommunity.softwareag.com/t/natural-statements-mask-or-is/202683/4 "2019-02-04T18:26:25Z")

</div>

To get the length of the contents of a variable use EXAMINE.

```auto
DEFINE DATA LOCAL
1 #A (A8) INIT <'12345'>
1 #L (I4)
END-DEFINE
EXAMINE #A FOR PATTERN '.' GIVING LENGTH #L
DISPLAY #A #L
END
```

```auto
Page 1 02/04/19 09:25:11
 
   #A #L
-------- -----------
 
12345 5
```

---

<div class="post-metadata">

**Author:** ![Prakash\_Parandhaman](https://avatars.discourse-cdn.com/v4/letter/p/eb8c5e/32.png) [@Prakash\_Parandhaman](https://techcommunity.softwareag.com/u/Prakash_Parandhaman)\
**Post date:** [February 4, 2019, 6:45pm UTC](https://techcommunity.softwareag.com/t/natural-statements-mask-or-is/202683/5 "2019-02-04T18:45:23Z")

</div>

Thanks… Is it not possible do via MASK stmt

---

<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:** [February 4, 2019, 10:26pm UTC](https://techcommunity.softwareag.com/t/natural-statements-mask-or-is/202683/6 "2019-02-04T22:26:17Z")

</div>

If valid values were restricted to alphabetic characters or numeric digits, then MASK could be used, as long as there were no leading or embedded spaces.

```auto
DEFINE DATA LOCAL
1 #A (A8) INIT <'AbCdEf'>
1 #L (I4)
END-DEFINE
IF #A = MASK (AAAAAAAA)
  THEN
    WRITE 'length is 8'
  ELSE
    IF #A = MASK (AAAAA' ')
      THEN
        WRITE 'length is 5'
      ELSE
        WRITE 'length is bad'
    END-IF
END-IF
END
```

```auto
DEFINE DATA LOCAL
1 #A (A8) INIT <'1234567'>
1 #L (I4)
END-DEFINE
IF #A = MASK (nnnnnnnn)
  THEN
    WRITE 'length is 8'
  ELSE
    IF #A = MASK (nnnnn' ')
      THEN
        WRITE 'length is 5'
      ELSE
        WRITE 'length is bad'
    END-IF
END-IF
END
```

But you can’t mix alpha and numeric because the mask for alphanumeric, C, includes ‘space’ as a valid character.

---

<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:** [February 5, 2019, 1:22am UTC](https://techcommunity.softwareag.com/t/natural-statements-mask-or-is/202683/7 "2019-02-05T01:22:57Z")

</div>

If there is a value of five characters are the last three characters always blanks?

If so, the most efficient solution would be:

1 #INPUT (a8)  
1 redefine #input  
2 filler 5x  
2 #lastthree (a3)

:::  
IF #lastthree = ’ ’ /\* three blanks in the apostrophes  
\*\* guaranteed a five character value  
else  
guaranteed an eight character value  
end-if

---

<div class="post-metadata">

**Author:** ![Prakash\_Parandhaman](https://avatars.discourse-cdn.com/v4/letter/p/eb8c5e/32.png) [@Prakash\_Parandhaman](https://techcommunity.softwareag.com/u/Prakash_Parandhaman)\
**Post date:** [February 5, 2019, 5:11am UTC](https://techcommunity.softwareag.com/t/natural-statements-mask-or-is/202683/8 "2019-02-05T05:11:31Z")

</div>

Thanks Ralph & Steve

---

<div class="post-metadata">

**Author:** ![Prakash\_Parandhaman](https://avatars.discourse-cdn.com/v4/letter/p/eb8c5e/32.png) [@Prakash\_Parandhaman](https://techcommunity.softwareag.com/u/Prakash_Parandhaman)\
**Post date:** [February 5, 2019, 5:20am UTC](https://techcommunity.softwareag.com/t/natural-statements-mask-or-is/202683/9 "2019-02-05T05:20:05Z")

</div>

Hi Steve,

Nope, the value on the field sometimes carries 3 or 5 or 8 byte of data and cant guarantee last characters with blank.

May be I can move the value to left justified and try it out

---

<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:** [February 5, 2019, 1:51pm UTC](https://techcommunity.softwareag.com/t/natural-statements-mask-or-is/202683/10 "2019-02-05T13:51:39Z")

</div>

Hi Prakash,

Originally you posed your problem with just 5 or 8 characters. You just changed that to 3, 5, or 8.

So which is it , 5-8 or 3-5-8 ?

If the last three characters are not blank for a 5 character value, how can you differentiate 5 from 8 characters? Can the first three characters be blank and the next 5 characters the value?

If it is really a 3-5-8 problem and not a 5-8 problem, what are the possibilities?

Would a three character value always have 5 leading blanks or 5 trailing blanks? Or, could it be, for example, bbXXXbbb, where X is a character and b a blank.

Please clarify the problem.

---

<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:42pm UTC](https://techcommunity.softwareag.com/t/natural-statements-mask-or-is/202683/11 "2021-04-02T15:42:15Z")

</div>


