HP 3000 Manuals

ASCII [ MPE/iX Intrinsics Reference Manual ] MPE/iX 5.0 Documentation


MPE/iX Intrinsics Reference Manual

ASCII 

NM and CM callable.

Converts a 16-bit binary number to a specified base and represents it as
a numeric ASCII string.

Syntax 
______________________________________________
|                                            |
|       I16             *     I16V   CA      |
|     numchar:=ASCII(binvalue,base,asciieqv);|
______________________________________________

            

Functional Return 

numchar               16-bit signed integer (assigned functional return) 

                      Returns the number of characters in the resulting
                      ASCII equivalent.

Parameters 

binvalue              type varies by value (required) 

                      Passes the binary number to be converted to an
                      ASCII string:

                         *   For octal conversions, binvalue must be a
                             16-bit unsigned integer.

                         *   For decimal conversions, binvalue must be a
                             16-bit signed integer.

                         *   For hexadecimal conversions, binvalue must
                             be a 16-bit unsigned integer

base                  16-bit signed integer by value (required) 

                      Passes and must be one of the following values or
                      the process aborts:

                         Value    Meaning 

                           8      Convert to octal (pad with zeros)

                          10      Convert to decimal (left-justify)

                          -10     Convert to decimal (right-justify)

                          16      Convert to hexadecimal (pad with zeros)

asciieqv              character array (required) 

                      Returns the converted value.  Must be long enough
                      to contain the result (<= 6 characters):

                         *   For octal conversions (base=8), 6 characters
                             (including leading zeros) are returned;
                             numchar returns the number of significant
                             (right-justified) characters (excluding
                             leading zeros).  If binvalue=0, the length
                             returned is 1.

                         *   For decimal conversions, binvalue is
                             considered a 16-bit, twos complement integer
                             ranging from -32768 to +32767.  If
                             binvalue=0, only one zero character is
                             returned in asciieqv; numchar returns the
                             total number of characters (including the
                             sign).  For example, if binvalue=0, the
                             length returned is 1; and if binvalue=327,
                             the length returned is 3.

                         *   For decimal left-justified conversions
                             (base=10), leading zeros are removed, and
                             the numeric ASCII result is left-justified
                             in asciieqv; the most significant digit (or
                             the "-" sign) is in asciieqv(1), the next
                             most significant digit is in asciieqv(2),
                             and so on.

                         *   For decimal right-justified conversions
                             (base=-10), the result is right-justified in
                             asciieqv; the least significant digit is in
                             asciieqv(-1), the next least significant
                             digit is in asciieqv(-2), and so on.

                         *   For right-justified conversions, the
                             character array where the converted value is
                             to be placed must specify the rightmost byte
                             where data is placed.  For example, if
                             asciieqv is a 10 byte array declared as:

                                  VAR
                                  MYSTRING : ARRAY [1..10] OF CHAR;

                             then you must specify it in the ASCII
                             intrinsic call as follows (for right
                             justification):

                                  NUMCHAR:=ASCII(VALUE,-10&
                                  ,WADDRESS(MYSTRING[10]));

                             The result is right-justified in asciieqv,
                             with the rightmost digit of the result
                             contained in the last (rightmost) byte of
                             asciieqv.

                         *   For hexadecimal conversions (base=16), 4
                             characters (including leading zeros) are
                             returned.  The digits can be 0..9 and A..F.
                             Numchar returns the number of significant
                             (right-justified) characters (excluding
                             leading zeros).  For example, if
                             binvalue=32, numchar is 2 and asciiqv will
                             be 0020.


NOTE For all right-justified conversions asciieqv must be initialized to blanks before the call is made.
Related Information Intrinsics DASCII, BINARY, DBINARY Commands None Manuals Data Types Conversion Programmer's Guide (32650-90015)


MPE/iX 5.0 Documentation