
  PROCEDURE [INLINE] cmp$prompt_for_answer
    (    prompt_1: string ( * <= 80);
         prompt_2: string ( * <= 80);
         error_prompt: string ( * <= 80);
         answer_table: cmt$answer_prompt_table;
     VAR selection: integer);

?? PUSH (LISTEXT := ON) ??
?? RIGHT := 110 ??

    VAR
      byte_address: amt$file_byte_address,
      file_position: amt$file_position,
      i: integer,
      j: integer,
      input_fid: amt$file_identifier,
      line: string (80),
      reply: string (80),
      status: ost$status,
      transfer_count: amt$transfer_count;

    selection := 0;
    clp$put_job_output (prompt_1, status);
    amp$open (clc$job_input, amc$record, NIL, input_fid, status);
    IF NOT status.normal THEN
      RETURN; {----->
    IFEND;

  /prompt/
    WHILE TRUE DO
      clp$put_job_output (prompt_2, status);
      line := ' ';
      amp$get_next (input_fid, ^line, #SIZE (line), transfer_count, byte_address, file_position, status);
      #TRANSLATE (osv$lower_to_upper, line, reply);

      IF reply = '?' THEN
        clp$put_job_output (' Available Commands:', status);
        clp$put_job_output ('', status);
        FOR i := 1 TO UPPERBOUND (answer_table) DO
          IF answer_table [i].long_answer_size > 0 THEN
            STRINGREP (line, j, ' ', answer_table [i].short_answer (1, answer_table [i].short_answer_size),
                  ', ', answer_table [i].long_answer (1, answer_table [i].long_answer_size));
          ELSE
            STRINGREP (line, j, ' ', answer_table [i].short_answer (1, answer_table [i].short_answer_size));
          IFEND;
          clp$put_job_output (line (1, j), status);

          IF answer_table [i].help_size <> 0 THEN
            STRINGREP (line, j, '        - ', answer_table [i].help (1, answer_table [i].help_size));
            clp$put_job_output (line (1, j), status);
          IFEND;
        FOREND;
        clp$put_job_output ('', status);

      ELSE
        FOR i := 1 TO UPPERBOUND (answer_table) DO
          IF ((answer_table [i].short_answer_size > 0) AND (reply = answer_table [i].short_answer)) OR
                ((answer_table [i].long_answer_size <> 0) AND (reply = answer_table [i].long_answer)) THEN
            selection := i;
            EXIT /prompt/ {----->
          IFEND;
        FOREND;

        clp$put_job_output (error_prompt, status);
      IFEND;
    WHILEND /prompt/;

    amp$close (input_fid, status);

  PROCEND cmp$prompt_for_answer;

*copyc clc$standard_file_names
*copyc cmt$answer_prompt_table
*copyc amp$close
*copyc amp$get_next
*copyc amp$open
*copyc clp$put_job_output
*copyc osv$lower_to_upper
?? POP ??

