?? RIGHT := 110 ??
?? NEWTITLE := 'NOS/VE : Interactive Facility' ??
?? NEWTITLE := '  [XDCL] iip$dpc64_to_string' ??
MODULE iim$dpc64_to_string;


{ Global Constants and Types
*copyc oss$job_paged_literal
*copyc IFV$MODULE_FOR_C180
?? SET (LIST := OFF) ??
*copyc iit$application_names_messages
?? SET (LIST := ON) ??
?? TITLE := 'PROCEDURE [XDCL] iip$dpc64_to_string', EJECT ??

  PROCEDURE [XDCL] iip$dpc64_to_string (VAR dpc: packed array [ * ] OF
    iit$display_code;
    dpc_length: integer;
    trailing_char_to_suppress: char;
    VAR str: string ( * );
    VAR str_length: integer);

    VAR
      ascii: [STATIC, READ, oss$job_paged_literal] string (64) :=
        ':ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+-*/()$= ,.#[]%"_!&''?<>@\^;',
      str_index: integer,
      dpc_index: integer,
      last_dpc: integer;

{ Determine the last display code character to convert

    IF dpc_length > ((UPPERBOUND (dpc) - LOWERBOUND (dpc)) + 1) THEN
      last_dpc := UPPERBOUND (dpc);
    ELSE
      last_dpc := LOWERBOUND (dpc) + dpc_length - 1;
    IFEND;

{ Convert DPC to ASCII

    str_index := 0;
    str_length := 0;
  /convert_to_string/
    FOR dpc_index := LOWERBOUND (dpc) TO last_dpc DO
      str_index := str_index + 1;
      IF str_index > STRLENGTH (str) THEN
        EXIT /convert_to_string/;
      IFEND;
      str (str_index) := ascii (dpc [dpc_index] + 1);
      IF str (str_index) <> trailing_char_to_suppress THEN
        str_length := str_index;
      IFEND;
    FOREND;

  PROCEND iip$dpc64_to_string;
MODEND
