Read expected data from the data area by analyzing the directory address area
This method can read Marc in ISO format and Marc in TXT format.
Code
/// <Summary>
/// Get Data
/// </Summary>
/// <Param name = "record"> Marc data </Param>
/// <Param name = "chnum"> Field number </Param>
/// <Param name = "subfield"> Subfield number </Param>
/// <Returns> Value </Returns>
Public String Getcontent ( String Record, String Chnum, String Subfield)
{
String Strdatacontent = String . Empty;
String Datazone;
String [,] Splitedmuci;
Int Loc;
Int Startloc;
Int Len;
Loc=Record. indexof ('@');
Datazone=Record. substring (loc+ 1);
Splitedmuci=Splitmucizone (record );
For ( Int I = 0 ; I < Splitedmuci. Length / 3 ; I ++ )
{
If (Splitedmuci [I, 0 ] = Chnum)
{
Startloc = Int . Parse (splitedmuci [I, 2 ]) - Getoffset (datazone, 0 , Int . Parse (splitedmuci [I, 2 ]);
Len = Int . Parse (splitedmuci [I, 1 ]) - Getoffset (datazone, Int . Parse (splitedmuci [I, 2 ]), Startloc + Int . Parse (splitedmuci [I, 1 ]);
Strdatacontent = Datazone. substring (startloc, Len - 1 );
}
}
If (Subfield = "" )
{
Return Strdatacontent;
}
Else
{
String [] Subdata = Strdatacontent. Split ( ' $ ' );
For ( Int I = 1 ; I < Subdata. length; I ++ )
{
String Ch = Subdata [I]. substring ( 0 , 1 );
If (CH = Subfield)
{
Strdatacontent = Subdata [I]. substring ( 1 , Subdata [I]. Length - 1 );
Break ;
}
}
}
Return Strdatacontent;
}
//Replace special characters
PublicStringReplacechr (StringResult)
{
Char[] Arr;
IntNum;
Arr = Result. tochararray ();
For ( Int I = 0 ; I < Arr. length; I ++ )
{
Num = Convert. toint32 (ARR [I]);
If (Num = 32 )
{
Arr [I] = ' # ' ;
}
Else If (Num = 30 )
{
Arr [I] = ' @ ' ;
}
Else If (Num = 31 )
{
Arr [I] = ' $ ' ;
}
Else If (Num = 29 )
{
Arr [I] = ' % ' ;
}
}
Result= New String(ARR );
ReturnResult;
}
// Separated by the Directory address length by 12
Public String [] Splitmuci ( String Strmuci)
{
Int Len = Strmuci. Length / 12 ;
String [] Splitedmuci = New String [Len];
For ( Int I = 0 , J = 0 ; J < Len; I + = 12 , J ++ )
{
Splitedmuci [J] = Strmuci. substring (I, 12 );
}
Return Splitedmuci;
}
/// <Summary>
/// Divide the directory address area into three parts and return the split result.
/// </Summary>
/// <Param name = "strarr"> Result returned by calling splitmuci </Param>
/// <Returns> </returns>
Public String [,] Getdata ( String [] Strarr)
{
Int Len = Strarr. length;
String [,] Datafield = New String [Len, 3 ];
For ( Int K = 0 ; K < Len; k ++ )
{
Int Count = 0 ;
For ( Int I = 0 , J = 3 ; Count < 3 ; I + = J, J ++ , Count ++ )
{
Datafield [K, Count] = Strarr [K]. substring (I, j );
}
}
Return Datafield;
}