× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



so...   you've got packed data that's in the middle of a string of bytes,
and you wish to use the MI builtins to get the hex nibbles that make up
that string, so that it can be converted to a real number, is that it?

>
> callp     $CtoH(w$hex:%subst(w$FldValue:1:a$Length(i)):
>                           a$length(i))
>

One confusing thing about these builtins is that when it says "cvthc"
it means "convert raw bits to hex characters" and when it says "cvtch" it
means "convert hex characters to raw bits".

In other words, they use "hex" instead of "binary", and the data that's
human-readable, even tho it's a representation of hex nibbles, is actually
called "character".

I think what you're doing wrong is calling $CtoH when you really wanted
to call $HtoC.

Here's some code that (hopefully) illustrates the difference:

     H DFTACTGRP(*NO) BNDDIR('QC2LE')

     D cvtch           PR                  ExtProc('cvtch')
     D   target                      26A
     D   src_chars                   52A   const
     D   source_len                  10I 0 value

     D cvthc           PR                  ExtProc('cvthc')
     D   target                      52A
     D   src_bits                    26A   const
     D   src_length                  10I 0 value

     D buf             S             26A
     D hexdump         S             52A

     C* Create hex dump of binary data
     c                   callp     cvthc(hexdump: 'HELLO': %size(hexdump))

     C* Create binary from hex nibbles
     c                   callp     cvtch(buf:  hexdump: %size(buf)*2)

     c                   dsply                   hexdump
     c                   dsply                   buf

     c                   eval      *inlr = *on



As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.