?? RIGHT := 110 ??
*copyc osd$default_pragmats
MODULE ram$get_deck_list;
?? PUSH (LISTEXT := ON) ??
*copyc rat$write_scl_commands
*copyc amp$open
*copyc amp$close
*copyc amp$put_next
*copyc amp$return
*copyc pmp$get_unique_name
*copyc clp$scan_command_line
?? POP ??

*copyc rah$get_deck_list

  PROCEDURE [XDCL] rap$get_deck_list (path_name: string (osc$max_string_size);
        path_name_size: 1 .. osc$max_string_size;
        file_name: ost$name;
    VAR status: ost$status);

    CONST
      number_of_commands = 7;

    VAR
      ba: amt$file_byte_address,
      command: array [1 .. number_of_commands] of rat$write_scl_commands,
      command_fid: amt$file_identifier,
      command_file: ost$name,
      i: 1 .. number_of_commands + 1,
      ignore_status: ost$status,
      size: integer,
      text: string (osc$max_string_size);

    pmp$get_unique_name (command_file, status);
    IF NOT status.normal THEN
      RETURN;
    IFEND;

    amp$open (command_file, amc$record, NIL, command_fid, status);
    IF NOT status.normal THEN
      RETURN;
    IFEND;

    STRINGREP (command [1].command, command [1].size, ' scu');
    STRINGREP (command [2].command, command [2].size, ' use_library b= ', path_name (1, path_name_size));
    STRINGREP (command [3].command, command [3].size, '   deck_list = $deck_list');
    STRINGREP (command [4].command, command [4].size, '   FOR i = 1 to $variable(deck_list,upper_bound) DO');
    STRINGREP (command [5].command, command [5].size, '     put_line l=deck_list(i) o=', file_name,
      '.$eoi');
    STRINGREP (command [6].command, command [6].size, '   FOREND');
    STRINGREP (command [7].command, command [7].size, ' quit wl=false');

    FOR i := 1 TO number_of_commands DO
      amp$put_next (command_fid, ^command [i].command, command [i].size, ba, status);
      IF NOT status.normal THEN
        RETURN;
      IFEND;
    FOREND;

    amp$close (command_fid, status);
    IF NOT status.normal THEN
      RETURN;
    IFEND;

    STRINGREP (text, size, ' include_file f=', command_file);
    clp$scan_command_line (text (1, size), status);
    IF NOT status.normal THEN
      RETURN;
    IFEND;

    amp$return (command_file, ignore_status);

  PROCEND rap$get_deck_list;
MODEND ram$get_deck_list;
