
#
# generated by genmod v1.0
#
# style booklist
#

$record_number = 0;

sub conv_booklist {
  local(%can) = @_;
  $record_number++;

  if (!defined $can{'CiteType'}) {
    &bib'gotwarn("required field CiteType is not defined");
    $can{'CiteType'} = 'book';
  }
  local($pp, $wp) = (undef,undef);
  $pp = $can{'Pages'}      if defined $can{'Pages'};
  $wp = $can{'PagesWhole'} if defined $can{'PagesWhole'};
  if ( (!defined $wp) && (defined $pp) && ($pp !~ /-|,/) ) {
    $wp = $pp;
    $pp = undef;
  }
  if (defined $can{'Authors'}) {
    $auth = $can{'Authors'};
  } elsif (defined $can{'Editors'}) {
    $auth = $can{'Editors'};
  } else {
    $auth = '(none)';
  }
  if (defined $oldauth) {
    if ($auth eq $oldauth) {
      $newauth = $endauth = undef;
    } else {
      $oldauth = $auth;
      $newauth = $endauth = '';
    }
  } else {
    $oldauth = $auth;
    $newauth = '';
    $endauth = undef;
  }
  # set default type using the CiteType field
  $type = &booklist_default_type($can{'CiteType'});

  # Initialize output string
  $str = '';

  if      ($type eq 'book') {
    $str .= " m1311${endauth}\n"        if defined ${endauth};
    if (defined ${newauth}) {
      local($tauth);
      $tauth = &bp_util'canon_to_name(${auth}, 'plain');
      $str .= "${newauth}m1300m0103$tauthm0113\n m1301\n";
    }
    if (defined $can{'Title'}) {
      $str .= "  m1300m2101$can{'Title'}m2111";
    }
  } 
  $str =~ s/,\s*$/./;
  $str;
}

sub booklist_default_type {
  local($citetype) = @_;
  local($type) = 'book';

  if (defined $citetype) {
    if ($citetype =~ /^(book)$/) {
      $type = $citetype;
    } else {
      &bib'gotwarn("Type '$can{'CiteType'}' not recognized -- using default type 'book'");
    }
  }
  $type;
}

1;
