*copyc OSD$DEFAULT_PRAGMATS
MODULE iim$store_context;
?? TITLE := 'MODULE iim$store_context' ??

?? PUSH (LISTEXT := ON) ??
*copyc amt$file_identifier
*copyc bat$task_file_table
*copyc bav$last_tft_entry
*copyc bav$task_file_table
*copyc ift$store_context_attributes
*copyc iiv$interactive_terminated
*copyc nat$data_fragments
*copyc osp$set_status_abnormal
*copyc OST$STATUS
*copyc ifp$fap_control
*copyc ifp$st_fap_control
?? POP ??

?? NEWTITLE := 'PROCEDURE iip$store_context', EJECT ??

  PROCEDURE [XDCL, #GATE] iip$store_context (file_id: amt$file_identifier;
        context_attributes: ift$store_context_attributes;
    VAR status: ost$status);

    VAR
      file_identifier: amt$file_identifier,
      file_id_is_valid: boolean,
      file_instance: ^bat$task_file_entry,
      i: integer,
      open_file_dsc_pointer: ^iit$open_file_description,
      st_open_file_dsc_pointer: ^iit$st_open_file_description;

    status.normal := TRUE;

    FOR i := LOWERBOUND (context_attributes) TO UPPERBOUND (context_attributes) DO
      CASE context_attributes [i].key OF
      = ifc$instance_mode =
        CASE iiv$network_identifier OF
        = iic$cdcnet_network =
        file_identifier := file_id;
*copy bai$validate_file_identifier
*copy iii$fetch_st_open_file_desc_ptr
          IF NOT status.normal THEN
            RETURN;
          IFEND;
        = iic$dsiaf_network =
        file_identifier := file_id;
*copy bai$validate_file_identifier
*copy iii$fetch_open_file_desc_ptr
          IF NOT status.normal THEN
            RETURN;
          IFEND;
        CASEND;
        iiv$previous_file_id := file_id;
        CASE  context_attributes [i].instance_mode OF
        = ifc$line =
          iiv$previous_mode := iic$line;
          CASE iiv$network_identifier OF
          = iic$cdcnet_network =
            st_open_file_dsc_pointer^.terminal_mode := iic$line;
          = iic$dsiaf_network =
            open_file_dsc_pointer^.terminal_mode := iic$line;
          CASEND;
        = ifc$screen =
          iiv$previous_mode := iic$screen;
          CASE iiv$network_identifier OF
          = iic$cdcnet_network =
            st_open_file_dsc_pointer^.terminal_mode := iic$screen;
            iiv$previous_connection_attr := st_open_file_dsc_pointer^.attributes;
          = iic$dsiaf_network =
            open_file_dsc_pointer^.terminal_mode := iic$screen;
            iiv$previous_connection_attr := open_file_dsc_pointer^.attributes;
          CASEND;
        CASEND;
      = ifc$blank_flag =
        iiv$previous_blank_flag := context_attributes [i].blank_flag;
      = ifc$screen_clear_string =
        iiv$screen_clear_string := context_attributes [i].screen_clear_string;
      ELSE
      CASEND;
    FOREND;

  PROCEND iip$store_context;

MODEND iim$store_context;
