?? RIGHT := 110 ??
MODULE ram$build_element_list;
*copyc osd$default_pragmats
?? PUSH (LISTEXT := ON) ??
*copyc rac$status_id
*copyc rav$class_types
*copyc rae$error_messages
*copyc rat$installation_table
*copyc rat$correction_package
*copyc rat$element_descriptor
*copyc osp$set_status_abnormal
*copyc osp$append_status_parameter
?? POP ??

*copyc rah$build_element_list

  PROCEDURE [XDCL] rap$build_element_list (table: ^rat$installation_table;
        name: ost$name;
    VAR element_list: ^array [1 .. * ] OF rat$element_descriptor;
    VAR last: rat$element_index;
    VAR status: ost$status);

    VAR
      found: boolean,
      found_in_table: boolean,
      i: rat$element_index,
      j: rat$element_index;

    status.normal := TRUE;

    IF name = 'ALL' THEN
      j := 1;
      FOR i := 1 TO UPPERBOUND (table^) DO
        IF (table^ [i].class <> rac$os_support) AND (table^ [i].class <> rac$none) AND (table^ [i].format <>
              rac$unused_format) AND (table^ [i].format <> rac$online_manual) AND (table^ [i].format <>
              rac$symbol_table) AND (table^ [i].format <> rac$real_state_library) AND (table^ [i].format <>
              rac$deadstart_tape_modules) AND (table^ [i].format <> rac$installation_table) THEN
          element_list^ [j].name := table^ [i].mnemonic_name;
          element_list^ [j].format := table^ [i].format;
          element_list^ [j].class := table^ [i].class;
          j := j + 1;
        IFEND;
      FOREND;
      last := j - 1;
    ELSEIF name = 'OS' THEN
      FOR i := 1 TO UPPERBOUND (table^) DO
        IF (table^ [i].class = rac$os) THEN
          j := 1;
          found := FALSE;
          WHILE (j <= last) AND NOT found DO
            IF element_list^ [j].name = table^ [i].mnemonic_name THEN
              found := TRUE;
            IFEND;
            j := j + 1;
          WHILEND;
          IF NOT found THEN
            last := last + 1;
            element_list^ [last].name := table^ [i].mnemonic_name;
            element_list^ [last].format := table^ [i].format;
            element_list^ [last].class := table^ [i].class;
          IFEND;
        IFEND;
      FOREND;
    ELSE
      j := 1;
      found := FALSE;
      WHILE (j <= last) AND NOT found DO
        IF element_list^ [j].name = name THEN
          found := TRUE;
        IFEND;
        j := j + 1;
      WHILEND;
      IF NOT found THEN
        found_in_table := FALSE;

      /get_one_element/
        FOR i := 1 TO UPPERBOUND (table^) DO
          IF table^ [i].mnemonic_name = name THEN
            IF (table^ [i].class = rac$os_support) OR (table^ [i].class = rac$none) THEN
              osp$set_status_abnormal (rac$status_id, rae$element_class_not_supported, name, status);
              osp$append_status_parameter (osc$status_parameter_delimiter, rav$class_types [table^ [i].class],
                    status);
              RETURN;
            IFEND;

            last := last + 1;
            element_list^ [last].name := table^ [i].mnemonic_name;
            element_list^ [last].format := table^ [i].format;
            element_list^ [last].class := table^ [i].class;
            found_in_table := TRUE;
            EXIT /get_one_element/
          IFEND;
        FOREND /get_one_element/;
        IF NOT found_in_table THEN
          osp$set_status_abnormal (rac$status_id, rae$element_not_in_install_tble, name, status);
          RETURN;
        IFEND;
      IFEND;
    IFEND;
  PROCEND rap$build_element_list;
MODEND ram$build_element_list;
