PROCEDURE label_tape_volumes, label_tape_volume, labtv (
  element_name, en: name = $optional
  vsn_prefix, vsnp: any of
      name 1..5
      string 1..5
      integer 1..99998
    anyend = $optional
  vsn_count, vsnc: integer 1..11881376 = $required
  character_set, cs: (by_name) key
      (ascii, a)
      (ebcdic, e)
    keyend = ascii
  file_accessibility_code, fac: (by_name, secure) string 1 = $optional
  increment_scheme, is: (by_name) key
      (alphabetic, a)
      (decimal, d)
    keyend = decimal
  label_standard_version, lsv: (by_name) string 1 = '4'
  owner_identifier, oi: (by_name, secure) string 1..14 = $optional
  type, t: (by_name) key
      mt9$800, mt9$1600, mt9$6250, mt18$38000
    keyend = osd$initv_type, mt9$1600
  volume_accessibility_code, vac: (by_name, secure) string 1 = $optional
  status)

"  The purpose of this procedure is to label a set
"  of tapes. The list of VSN's for the tapes are generated by
"  pup$construct_volume_list.  The values of the VSNs depends on the values for
"  vsn_prefix, vsn_count and increment_scheme.
"
"  This process uses the initialize_tape_volume subcommand of the
"  system_operator_utility to label the backup tapes. There will
"  not be a normal tape request when doing this. A message will appear
"  in the operator action window, please ready (element_name). When a
"  tape is mounted and the drive is ready the menu for labeling tapes
"  will describe the label operation about to be executed and ask for
"  confirmation. This process will repeat until all tapes have been
"  labelled.
"
"  PARAMETERS:
"    element_name, en: Specify the element name of the tape drive on which
"       you are going to label the backup tapes.  The element name must be
"       omitted for volumes that are robotically mounted since the system
"       will select the element name but must be specified for volumes that
"       are manually mounted.
"
"    vsn_prefix, vsnp: Specify a one to five character name, string or integer
"      that will become the leftmost characters in the list of VSN's generated
"      by the procedure.
"
"    vsn_count, vsnc: The number of backup tapes in the set.
"
"    character_set, cs: This parameter determines the character
"      set (ASCII or EBCDIC) used in recording the labels on tape.
"
"    file_accessibility_code, fac: This parameter specifies the file
"      accessibility code that is written into the accessibility code
"      field of the HDR1 label.
"
"    increment_scheme, is: This parameter determines the format for the
"      rightmost characters of the VSN's generated by this procedure.
"      Decimal mode is the default. Alphabetic mode is for situations
"      where a decimal increment scheme does not allow enough tapes.
"
"    label_standard_version, lsv: This parameter specifies the version
"      number of the ANSI standard to record on the tape volume label.
"
"    owner_identifier, oi: This parameter specifies the name of the tape
"      owner.
"
"    type, t: This parameter specifies the density of the backup tapes
"      you are using.
"
"    volume_accessibility_code, vac: This parameter specifies the volume
"      accessibility code that is written into the accessibility code field
"      of the VOL1 label.
"
" VSN Generation Examples:
"   vsn_prefix=part vsn_count=12 increment_scheme=decimal    ==>part01-part12
"   vsn_prefix=part vsn_count=12 increment_scheme=alphabetic ==>partaa-partal
"
"   vsn_prefix=A1 vsn_count=27 increment_scheme=decimal    ==>A10001-A10027
"   vsn_prefix=A1 vsn_count=27 increment_scheme=alphabetic ==>A1AAAA-A1AABA

"$FORMAT=OFF
VAR
  label_tape_volume_status: status
  vsn_list: list 1 .. $max_list of string 6
VAREND
"$FORMAT=ON

  pup$construct_volume_list vsn_count=vsn_count vsn_prefix=vsn_prefix increment_scheme=increment_scheme ..
        volume_list=vsn_list

  FOR i = 1 TO vsn_count DO
    IF $specified(element_name) THEN
      initialize_tape_volume element_name=element_name recorded_vsn=vsn_list(i) type=type ..
            owner_identifier=owner_identifier volume_accessibility_code=volume_accessibility_code ..
            file_accessibility_code=file_accessibility_code character_set=character_set ..
            label_standard_version=label_standard_version status=label_tape_volume_status
    ELSE
      initialize_tape_volume recorded_vsn=vsn_list(i) type=type ..
            owner_identifier=owner_identifier volume_accessibility_code=volume_accessibility_code ..
            file_accessibility_code=file_accessibility_code character_set=character_set ..
            label_standard_version=label_standard_version status=label_tape_volume_status
    IFEND
    IF NOT label_tape_volume_status.normal THEN
      put_line ' ** WARNING ** LABEL_TAPE_VOLUMES encountered the following abnormal status.' o=$output
      display_value label_tape_volume_status
      EXIT_PROC
    IFEND
  FOREND

PROCEND label_tape_volumes
