package C4::test;
use strict;
require Exporter;
use C4::Database;
use C4::Catalogue;

our $dbh=&C4Connect;
$dbh->do("delete from marc_subfield_table");
$dbh->do("delete from marc_blob_subfield");
&MARCaddSubfield(1,'001',1,'##','a',1,'1 - This is a value');
&MARCaddSubfield(1,'001',1,'##','b',1,'2 - This is another value');
&MARCaddSubfield(1,'001',1,'##','c',1,"3 - This is a value very very long. I try to make it longer than 255 char. I need to add something else. will it be long enough now... I'm not sure. That's why i continue to add a few word to this very important sentence. Now I hope it will be enough... Oh, not it need some more characters. So i add stupid strings : xxxxxxxxxxxxxxx dddddddddddddddddddd eeeeeeeeeeeeeeeeeeeeeee rrrrrrrrrrrrrrrrrrr ffffffffffffffffff");
&MARCaddSubfield(1,'001',1,'##','d',1,"4 - This is another value very very long. I try to make it longer than 255 char. I need to add something else. will it be long enough now... I'm not sure. That's why i continue to add a few word to this very important sentence. Now I hope it will be enough... Oh, not it need some more characters. So i add stupid strings : xxxxxxxxxxxxxxx dddddddddddddddddddd eeeeeeeeeeeeeeeeeeeeeee rrrrrrrrrrrrrrrrrrr ffffffffffffffffff");
print "change 1\n";
&MARCchangeSubfield(1,"1new - this is a changed value");
print "change 2\n";
&MARCchangeSubfield(2,"2new - go from short to long subfield... uuuuuuuuuuuuuuuuuuuuuuuu yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy tttttttttttttttttttttttttttttttt rrrrrrrrrrrrrrrrrrrrrr eeeeeeeeeeeeeeeeeeeeeeeee zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq ssssssssssssssssssssssssss ddddddddddddddddddddddddddddddd fffffffffffffffffffffffff ggggggggggggggggggggggggg hhhhhhhhhhhhhhhhhhhhhhhhhh jjjjjjjjjjjjjjjjjjjjjkkkkkkkkkkkkkkkkkkkkkkkk");
print "change 3\n";
&MARCchangeSubfield(3,"3new - go from long to short subfield...");
print "change 4\n";
&MARCchangeSubfield(4,"4new - stay with blob subfield...uuuuuuuuuuuuuuuuuuuuuuuu yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy tttttttttttttttttttttttttttttttt rrrrrrrrrrrrrrrrrrrrrr eeeeeeeeeeeeeeeeeeeeeeeee zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq ssssssssssssssssssssssssss ddddddddddddddddddddddddddddddd fffffffffffffffffffffffff ggggggggggggggggggggggggg hhhhhhhhhhhhhhhhhhhhhhhhhh jjjjjjjjjjjjjjjjjjjjjkkkkkkkkkkkkkkkkkkkkkkkk");
my $x= &MARCfindSubfield(1,'001','a','',1);
my $record= MARC::Record->new();
$record->leader("58973");
$record->add_fields('100',1,'',a => 'Logan, Robert K.', d => '1000-');
$record->add_fields('110',1,'',d => '1939-');

my $record2=MARCkoha2marc("123456","author","title","unititle","notes","abstract",
	"serial","seriestitle","copyrightdate","biblioitemnumber","volume","number",
	"classification","itemtype","isbn","issn",
	"dewey","subclass","publicationyear","publishercode",
	"volumedate","illus","pages","notes",
	"size","place","lccn");
&MARCaddMarcBiblio($record2);
# parse all subfields 
my @fields = $record->fields();
foreach my $field (@fields) {
    my @subf=$field->subfields;
    for my $i (0..$#subf) {
#    print $field->tag(), " ", $field->indicator(1),$field->indicator(2), "subf: ", $subf[$i][0]," =",$subf[$i][1]," <-- \n";
}
}
#print $record->as_formatted();
