# How to hexdump dynamic alphas?

**URL:** <https://techcommunity.softwareag.com/t/how-to-hexdump-dynamic-alphas/174400>\
**Category:** Forum\
**Tags:** Adabas-Natural, Natural, Natural-on-Linux\
**Created:** [February 11, 2014, 3:23pm UTC](https://techcommunity.softwareag.com/t/how-to-hexdump-dynamic-alphas/174400 "2014-02-11T15:23:48Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Matthias1](https://avatars.discourse-cdn.com/v4/letter/m/9fc348/32.png) [@Matthias1](https://techcommunity.softwareag.com/u/Matthias1)\
**Post date:** [February 11, 2014, 3:23pm UTC](https://techcommunity.softwareag.com/t/how-to-hexdump-dynamic-alphas/174400/1 "2014-02-11T15:23:48Z")

</div>

Hello all!

Hexdumping a fixed length alpha is very easy. But what about dynamics?

```auto
define data local
01 #a10 (A10) init <'ABC'>
01 #a (A) dynamic init <'123'>
01 #hex (A) dynamic
end-define
move edited #a10 (EM=H(10)) to #hex
display #hex (AL=70)
move edited #a (EM=H(??)) to #hex /* how to do that?
display #hex (AL=70)
end
```

Do I really have to code a for loop?

regards

Matthias

---

<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 11, 2014, 5:30pm UTC](https://techcommunity.softwareag.com/t/how-to-hexdump-dynamic-alphas/174400/2 "2014-02-11T17:30:03Z")

</div>

Using an intermediate variable (#HEX) will cause storage problems, but dumping the value is easy - the first half, anyway.

Since the longest string can be (A1073741824), the longest edit mask can be half that.

```auto
DEFINE DATA LOCAL
1 #D (A) DYNAMIC INIT <'abc'>
END-DEFINE
PRINT #D (EM=H(536870912))
END
```

---

<div class="post-metadata">

**Author:** ![Matthias1](https://avatars.discourse-cdn.com/v4/letter/m/9fc348/32.png) [@Matthias1](https://techcommunity.softwareag.com/u/Matthias1)\
**Post date:** [February 12, 2014, 8:42am UTC](https://techcommunity.softwareag.com/t/how-to-hexdump-dynamic-alphas/174400/3 "2014-02-12T08:42:38Z")

</div>

You’re right, it’s quite easy. But I can’t see the storage problem you mentioned…

```auto
define data local
01 #b2 (B2 ) init <H'01'>
01 #a (a) dynamic
end-define
write #b2
move edited #b2 (EM=H(536870912)) to #a
write *LENGTH(#a) #a (AL=20)
end
```

---

<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 12, 2014, 9:32am UTC](https://techcommunity.softwareag.com/t/how-to-hexdump-dynamic-alphas/174400/4 "2014-02-12T09:32:25Z")

</div>

The original code example used a temporary variable, #HEX. The following code Checks but won’t Run.

```auto
DEFINE DATA LOCAL
1 #D (A) DYNAMIC INIT <'abc'>
1 #HEX (A1073741824)
END-DEFINE
MOVE EDITED #D (EM=H(536870912)) TO #HEX
PRINT #HEX #D (EM=H(536870912))
END
```

---

<div class="post-metadata">

**Author:** ![Matthias1](https://avatars.discourse-cdn.com/v4/letter/m/9fc348/32.png) [@Matthias1](https://techcommunity.softwareag.com/u/Matthias1)\
**Post date:** [February 12, 2014, 10:11am UTC](https://techcommunity.softwareag.com/t/how-to-hexdump-dynamic-alphas/174400/5 "2014-02-12T10:11:28Z")

</div>

To avoid dealing with additional variables I coded a simple function. Plus I want to hexdump B-fields, too. This is my second function.

```auto
define function #A2hex
  returns (A) dynamic
  define data parameter
  1 #A (A) dynamic by value
  end-define
  move edited #A (EM=H(536870912)) to #A2hex
end-function
end
*****
define function #b2hex
  returns (A) dynamic
  define data parameter
  1 #b (B) dynamic by value
  end-define
  move edited #b (EM=H(536870912)) to #b2hex
end-function
end
```

Try this:

```auto
define data local
01 #b2 (B2) init <H'0001'>
end-define
write #b2hex(<H'0001'>) (AL=10)
write #b2hex(<#b2 >) (AL=10)
write #a2hex(<H'0001'>) (AL=10)
write #a2hex(<#b2 >) (AL=10)
end
```

My output is:  
0001  
0001  
0001  
31

So when converting #b2 to (A) dynamic, the value of #b2 is treated as an unsigned integer. A real trap for the unwary…

---

<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:30pm UTC](https://techcommunity.softwareag.com/t/how-to-hexdump-dynamic-alphas/174400/6 "2021-04-02T15:30:18Z")

</div>


