Jump to page titleUNITED STATES
hp.com home products and services support and drivers solutions how to buy
» contact hp

:

more options
 

hp.com home
End of Jump to page title
Example-PLI How To Convert Data Items Using LIB$CVT_DX_DX
Jump to content



» 

business support center

Home & Home Office Support:
» HP branded products
» Presario branded products
» Services & Warranties
Small & Medium Business Support:
» Small & Medium Business products
» Small & Medium Business services
Support for IT Professionals:
» Enterprise products (IT Resource Center)
» NonStop enterprise products
» Business & IT Services
Content starts here
Copyright (c) Digital Equipment Corporation 1988. All rights reserved
LAYERED PRODUCT or COMPONENT: PLI, VERSION 3.1     OP/SYS: VMS V5.0

SOURCE:     Digital Customer Support Center



OVERVIEW:

This program demonstrates how to use the Run Time Library Routine,
LIB$CVT_DX_DX, to convert a character string to a fixed binary number.

CAUTION:  This sample program has been tested using PLI, Version
3.1 on operating system VMS, Version 5.0.  However, we cannot
guarantee its effectiveness because of the possibility of errors
in transmission or implementation.  It is meant to be used as a
template for writing your own program, and it may require modification
for use on your system.


PROGRAM NOTES:

This program builds its own descriptor blocks for the conversion call.


PROGRAM SAMPLE:

CONVERT: proc options(main);
/* For more information on LIB$CVT_DX_DX, see Volume 8B "Run Time
   Library Routines pages RTL 48 through 53, 1-26 through 1-27, 1-30,
   2-11 through 2-14, and Volume 8A "Introduction to System Routines." */

%include LIB$CVT_DX_DX;

%include $libdef;
%include $DSCDEF;
%include $stsdef;
/*  value to be converted */
     dcl nz_value                   char(4);
/*  value after conversion */
     dcl nro_value                   fixed bin(31);
/*  value for arithmetic operation */
     dcl testno                      fixed bin(31);
     dcl dest_size                   fixed bin(15);
/* type t is for character */
     dcl k_dtype_d                   fixed bin(7) init(dsc$k_dtype_t);
/* type l is for  longword integer */
     dcl k_dtype_t                   fixed bin(7) init(dsc$k_dtype_l);
     dcl k_class_s                   fixed bin(7) init(dsc$k_class_s);

/* set the source descriptor block for the number being converted */
    dcl 01  source_item,
            03  source_length           fixed bin(15) init(4),
            03  source_type             fixed bin(7),
            03  source_class            fixed bin(7),
            03  source_address          pointer;

/*   set up the descriptor for the item that is being returned */
    dcl 01  dest_item,
            03  dest_length             fixed bin(15) init(4),
            03  dest_type               fixed bin(7),
            03  dest_class              fixed bin(7),
            03  dest_address            pointer;

        source_address = addr(nz_value);
    dest_address = addr(nro_value);
START:
    put skip list('Enter the charater string=');
    get list (nz_value);

        source_type =  k_dtype_d;
        dest_type =  k_dtype_t;
        source_class = k_class_s;
        dest_class = k_class_s;

        sts$value =  LIB$CVT_DX_DX(ref(source_item),ref(dest_item),
                                       dest_size);
        if ^STS$SUCCESS
          then do;
             if sts$value = lib$_invnbds
                 then do;
                    put skip list('Invalid data type');
                    go to start;
                 end;
               put skip list('Failure call to LIB$CVT_DX_DX',
                              sts$value);
               signal VAXCONDITION(sts$value);
          end;

        put skip list('The converted value =', nro_value);
        testno = nro_value + 1;
        put skip list('To check the validity of the number, 1 was added=',
                       testno);
  end CONVERT;




buy online or call 1.800.AT.COMPAQ
privacy statementusing this site means you accept its terms