
  PROCEDURE [INLINE] cmp$convert_channel_number
    (    channel_number: ost$physical_channel_number;
         concurrent: boolean;
         port: cmt$channel_port;
     VAR channel_ordinal: cmt$channel_ordinal;
     VAR channel_name: cmt$element_name;
     VAR valid: boolean);

?? PUSH (LISTEXT := ON) ??

    VAR
      divisor: 1 .. 1000,
      i: 0 .. 4,
      j: 0 .. 0f(16),
      number_of_chars : 0 .. 4,
      number_string: string (4),
      ordinal_number: integer,
      port_char : string (1),
      start: integer;

    { PURPOSE : This inline routine converts a physical channel number into
    {    its equivalent channel ordinal and the externalized channel name.
    { DESIGN : This routine can be called from a Monitor or Job mode module.
    { NOTE : cmt$channel_ordinal is a CM type that will be deleted. Avoid
    {    using this type.


    IF (channel_number < 0) OR (channel_number > 33(8)) THEN
      valid := FALSE;
      RETURN;
    ELSE
      valid := TRUE;
      number_string := ' ';
      port_char := ' ';
      divisor := 1;
      #SPOIL(divisor);
      IF channel_number <= 9 THEN
        number_of_chars := 1;
      ELSEIF (channel_number >= 10) AND (channel_number <= 99) THEN
        number_of_chars := 2;
      ELSE
        number_of_chars := 3;
      IFEND;
      FOR i := number_of_chars DOWNTO 1 DO
        number_string (i, 1) := $CHAR (((channel_number DIV divisor) MOD
              10) + $INTEGER ('0'));
        divisor := divisor * 10;
        #SPOIL(divisor);
      FOREND;
      IF concurrent THEN
        channel_name := 'CCH';
        start := 4;
        CASE port OF
        = cmc$port_a =
          port_char := 'A';
        = cmc$port_b =
          port_char := 'B';
        ELSE
        CASEND;
      ELSE
        channel_name := 'CH';
        start := 3;
      IFEND;
      j := 0;
      #SPOIL(j);
      FOR i := 1 TO 4 DO
        IF number_string (i, 1) <> ' ' THEN
          channel_name (start + j, 2) := number_string (i, 1);
          j := j + 1;
          #SPOIL(j);
        IFEND;
      FOREND;
      IF port_char <> ' ' THEN
        j := 1;
        #SPOIL(j);
        WHILE (channel_name (j, 1) <> ' ') DO
          j := j + 1;
          #SPOIL(j);
        WHILEND;
        channel_name (j, 1) := port_char;
      IFEND;

      {  Determine channel ordinal.

      IF concurrent THEN
        IF port = cmc$unspecified_port THEN
          ordinal_number := $INTEGER (cmc$cio_channel0);
        ELSE  { port A or port B channel }
          IF channel_number <= 9 THEN
            ordinal_number := $INTEGER (cmc$cio_channel0_porta);
          ELSE

            { Set up this number because of the gap between Cio channel 9 and
            { Cio channel 16.

            ordinal_number := 16;
          IFEND;
        IFEND;

      /cio_channel_loop/
        FOR channel_ordinal := cmc$cio_channel0_porta TO
              UPPERVALUE (cmt$channel_ordinal) DO
          IF port = cmc$unspecified_port THEN
            IF (channel_number = ($INTEGER (channel_ordinal) - ordinal_number)) THEN
              EXIT /cio_channel_loop/;
            IFEND;
          ELSE
            IF (channel_number = ($INTEGER (channel_ordinal) - ordinal_number) DIV 2) THEN
              IF port = cmc$port_b THEN
                IF ((($INTEGER (channel_ordinal) - ordinal_number) MOD 2) <>
                    1) THEN
                  CYCLE /cio_channel_loop/;
                IFEND;
              IFEND;
              EXIT /cio_channel_loop/;
            IFEND;
          IFEND;
        FOREND /cio_channel_loop/;
      ELSE
      /nio_channel_loop/
        FOR channel_ordinal := LOWERVALUE (cmt$channel_ordinal)
              TO cmc$channel27 DO
          IF channel_number = $INTEGER (channel_ordinal) THEN
            EXIT /nio_channel_loop/;
          IFEND;
        FOREND /nio_channel_loop/;
      IFEND;
    IFEND;

  PROCEND cmp$convert_channel_number;

?? POP ??
?? PUSH (LISTEXT := ON) ??
*copyc cmt$element_name
*copyc cmt$channel_ordinal
*copyc cmt$channel_port
*copyc ost$physical_channel_number
?? POP ??
