czech version | english version
  
     About
 
     Manual
 
     Support
 
     Download
  
Multidata » MarcMan  » MarcMan - manual

   1. Installation
           a) Distribution packages
           b) Installation procedure
   2. Initiation
           a) Inititation in batch processing mode
           b) Initiation in the client/server mode
   3. Configuration files
           a) Configuration file example
           b) Configuration file structure
           c) Configuration file parameters
                  SourceFile
                  SourceFormat
                  DestinationFile
                  DestinationFormat
                  InRecordErrorFile
                  InRecordOKFile
                  IDAlephCoding
                  RulesFile
                  CodeFile
                  TablesDirectory
                  LogFile
                  EnableLogAll
                  ControlFile
                  PluginsDirectory
                  Plugins
   4. Error message
   5. Record formats
           a) ISO format
                  Description
                  Definition
           b) System Aleph 500 format
                  Description
                  Definition
                  Example
           c) Text format
                  Description
                  Definition
                  Example
   6. Record processing rules
           a) Rule file structure
                  Comments
           b) Record access expressions
                  Rules to access the indicators of the fields, subfields and inserted fields
                  Special rules
                  Multiple rules (construction GROUP)
           c) UseScript Language
                  Key words
                  Operators
                  Control structures
                  Variables
                  Functions
           d) Table files
   7. Records control
           a) Fields and subfields entity symbol
           b) Value listing symbols in the indicator
           c) Value length symbols
           d) Value listing symbol in the subfield positions
           e) Inserted fields symbols
           f) Detailed control
   8. Plugins
           a) Installation
           b) Plugin md5
                  Description
                  Functions provided
           c) Plugin unicode
                  Description
                  Functions provided

MarcMan

1. Installation

a) Distribution packages

Convertor is distributed in form of a package, that apart from the executable program file includes many other files described below.


These packages are distributed for Alpha (Tru64 UNIX)platform:


  • marcman-tru64.tar.gz

  • marcman-server-tru64.tar.gz



These packages are distributed for Linux platform:


  • marcman-linux.tar.gz

  • marcman-server-linux.tar.gz



This package is distributed for MS Windows platform:


  • marcman-win32.zip


Packages bearing a word server in their name include client/server type installation, which to this date is only available for unix type platforms. Other packages include a record batch processing version.


b) Installation procedure

Create a directory for the convertor installation (to keep it simple, we will be refering to the directory as $MARCMAN_HOME) on the disc.


Save the distribution package into the $MARCMAN_HOME directory and open it.


On unix type platforms the opening can be done e.g. this way:


cd $MARCMAN_HOME 
gunzip marcman-tru64.tar.gz 
tar xvf marcman-tru64.tar


On the MW Windows platforms use one of the numerous archiving programs (e.g. WinRAR or WinZIP) for distribution package opening. Check, if after the opening, the executable file MarcMan is in $MARCMAN_HOME directory, in other words, that the archiving program didn't create other subdirectory at the opening process (if so, copy the content of the newly created subdirectory directly into the $MARCMAN_HOME directory, and delete the particular subdirectory.


The following directory structure is created on the disc in $MARCMAN_HOME directory, after the distribution package opening:


$MARCMAN_HOME/      
      data/      
      modules/   
          c_marc21_unimarc/
             tbl/
             run.cfg
             conversion.rul
             marc21.ctr	    
	  .
          .
      out/
      plugins/
      marcman
      run_marc21_unimarc.bat
      run_marc21_unimarc_authority.bat
      run_unimarc_marc21.bat
      run_unimarc_marc21_authority.bat 


The meaning of each item is following:


Directory

Utilization

data/

Data examples in various testing formats. You define the source data in the configuration file , where you can of course change them.

modules/

Modules.

modules/c_marc21_unimarc

Conversion module marc21->unimarc. You can find more of those modules in the modules directory.

modules/c_marc21_unimarc/tbl/

Directory with tables for a particular conversion by a particular module. You can find more in the TablesDirectory parameter description.

modules/c_marc21_unimarc/run.cfg

Example of configuration file for particular module conversion.

modules/c_marc21_unimarc/conversion.rul

Conversion rules file. How to write rule files, please see Record processing rules chapter. If you only own program's light version, this file will have .crul suffix and won't be readable.

modules/c_marc21_unimarc/marc21.ctr

Conversion control file. How this file should look like, please see Control file chapter.

out/

Directory, where conversion results are saved. You define this directory in the configuration file, where you can of course change it.

plugins/

Plugin directory. For more see Pluginy chapter.


Directory structure can vary in the particular distribution, principle and file suffixes remain the same.


Add $MARCMAN_HOME/bin path into the PATH variable, in order to avoid setting program's full path at the convertor's initiation. Method of adding a path to the PATH variable varies, depending on the type of the operation system (on the unix type platforms also depending on the shell and distribution). That's why, the set-up is not described here, however, it shouldn't be a problem to find more about procedure in the operation system documentation.




2. Initiation

Initiation method depends on the operation mode, which means, it is different for batch processing mode and different for client/server mode.


a) Inititation in batch processing mode

In the batch processing mode the convertor is initiated when a single argument is passed to the particular program (MarcMan); which is a path to the configuration file, where all other necessary parameters are defined. (see configuration files).

MarcMan <configuration file>


Convertor initiation is processed for example as follows:


on MS Windows platform:

MarcMan C:\marcman\run.cfg

on unix type platform:

MarcMan ~/marcman/run.cfg


Attention! You must have an appropriate distribution package for the initiation in the batch processing mode. Which means, if you only have a distribution package for the operation in the client/server mode, the operation is not possible in the batch processing mode ( marcmand program is used for the client/server mode).


After the convertor initiation in the batch processing mode, the following steps are performed:


  • Reading of the configuration file

  • Reading of the record processing rules

  • Counting of the records in the input file

  • Reading and processing of the records in the input file

  • Completion of the convertor's activity


b) Initiation in the client/server mode


Like in the batch processing mode, the convertor in the client/server mode is initiated, when a single argument is passed to the particular program (marcmand); which is a path to the configuration file, where all other necessary parameters are indicated (see configuration files).


marcmand <configuration file>


Convertor's server initiation is processed e.g. as follows:


only on the unix type platform:

marcmand ~/marcman/run.cfg


Attention! You must have an appropriate distribution package for the initiation in the batch processing mode. Which means, if you only have a distribution package for the operation in the batch processing mode, the operation is not possible in the client/server mode (another type of program is used for the block processing mode - MarcMan).


After the convertor's server initiation in the client/server mode, the following steps are performed:


  • Reading of the configuration file

  • Reading of the record processing rules

  • Initiation on the running process background

  • Listening on the running process background on the unix socket or TCP/IP port and processing of the records sent to this port.

  • Contigent ending on the running process background by user intervention (using the command kill)


The convertor's client (marcc) is used for sending the record (or more records) to the particular port, on which the convertor's server is listening. Convertor's client is initiated by two arguments:


marcc <protocol> <server address:port>

First argument is a protocol, which should be used for communication with the server, and second one is the server address (if need be including a port).

Supported protocols are following:


  • unix - for communication through the unix sockets (in this case the address is the unix socket path)

  • tcp - for communication through TCP/P protocol (in this case the address is the server name followed by a sign : (colon) and by the port number)


Transfer of the record to be processed is carried out e.g. as follows:

The server listening on the unix socket:

marcc unix marcmand.sock <zaznamy.iso

or

cat zaznamy.iso | marcc unix marcmand.sock


The server listening on TCP/IP port 12345 on the host.somewhere.com server:


marcc tcp host.somewhere.com:12345 <records.iso

or

cat records.iso | marcc tcp host.somewhere.com:12345


After the converter’s client initiation, the following steps are performed:


  • Reading of the record from the standard input

  • Sending of the records to the particular port

  • (records processing by the converter’s server)

  • Reading of the processed record from a particular port

  • Print of the processed record on the standard output


Main advantage of the operation in the client/server mode is a higher speed of data processing (there is no necessity of repetitive reading of the configuration files and rules (they are read only once at the converter’s server start). Moreover, it is possible to initiate processing of more records concurrently.

On the contrary the disadvantage could be an impossibility of executing some of the operations, that have a reason only at a batch processing, when it is guaranteed, that a converter process is running only once (e.g. the functions for the user write into the file, can't be used in the rules).


3. Configuration files


If you want to start processing (converting, controlling, filtrating etc.) some of the records, first you have to give specific input parameters to the converter. Above all, these parameters determine the mode of the converter’s work (client/server or batch processing), records input format (e.g. iso format, text format, system Aleph 500 format etc.), input, from where the records should be taken for the processing, records output format, output, where the processed records should be saved, which rules should be used for the processing etc.


Parameters are written into the configuration file (it usually has cfg suffix, e.g. run.cfg). Configuration file path is then passed on to the converter as the only obligatory argument at the process of initiation (see initiation chapter).

a) Configuration file example


[INPUT] 
SourceFile=c:/marcman/data/output/records.iso 
SourceFormat=iso  

[OUTPUT]  
DestinationFile=C:/marcman/output/out.alf 
DestinationFormat=aleph 
InRecordErrorFile=C:/marcman/data/output/out_err.iso 
InRecordOkFile=C:/marcman/data/output/out_ok.iso 
IDAlephCoding=L  

[RULES] 
RulesFile=C:/marcman/rules/conversion.rul
TablesDirectory=C:/marcman/tables/ 
LogFile=C:/marcman/log/log.txt 
EnableLogAll=No


b) Configuration file structure

The parameters are indicated in the configuration file in form of:


parameter name=value

E.g.

SourceFile=C:/marcman/data/input/records.iso


Attention! – Parameter names are case sensitive, which means, that is necessary to indicate the parameter name precisely in a form, that is described below.


Apart from parameters themselves, there could be even other lines in the file, where it applies, that all lines, where there is no occurrence of = sign(equals), are ignored at the reading process. Conversely, the lines including = sign (equals) are considered as a definition of the parameter with a value, that equals to a text shown after the first = sign (equals).

For better orientation in the structure, the following write conventions are used.

In front of the group of the parameters, that relate to each other, there is a label indicated in the square brackets, that gives a name to this group. For better clarity there is an empty line behind the group .


E.g.


[INPUT] 
SourceFile=C:/marcman/data/input/records.iso 
SourceFormat=iso


c) Configuration file parameters

Basic parameters, that are possible (and in some cases even necessary) to define in the configuration file, are indicated in the following table. Some of the rules can require additional definition of some other parameters, then their specification is the part of the documentation supplied to particular rules, if need be, along with those rules a configuration file sample is supplied, that can then be modified with regard to a local environment.


SourceFile

Description:


SourceFile parameter defines a path to the file including the input records.

Obligation:

Obligatory for the batch processing mode, it is not meaningful for the client/server mode.

Notes:

Attention! - each directory must be separated by / (slash) sign in the file and directory paths, whatever the operating system is.


Example:

SourceFile=data/marc21/record02.txt

SourceFormat

Description:

SourceFormat Parameter defines input data format

Admissible values

Obligation:

Obligatory for both modes of processing.

Notes:

Attention! – The converter won’t be working correctly if there is an inconsonance of a input file format with a format indicated in this parameter.

Example:

SourceFormat=txt

DestinationFile

Description:

DestinationFile parameter defines a file path, where the well converted records should be saved in.

Obligation:

Obligatory for the batch processing mode, it is not meaningful for the client/server mode.

Notes:

Attention! – the file is overwritten at each convertor's initiation

Attention! - each directory must be separated by / (slash) sign in the file and directory paths, whatever the operating system is.

Example:

DestinationFile=out/vystup_out.txt

DestinationFormat

Description:

DestinationFormat parameter defines a input data format.

Convertor's current version recognizes the following file formats:



Obligation:

Obligatory for both modes of processing.

Notes:

Attention! – The converter won’t be working correctly if there is an inconsonance of a input file format with a format indicated in this parameter.

Attention! – if Aleph 500 system format is indicated as a format, it is also necessary to specify IDAlephCoding parameter.

Example:

DestinationFormat=txt

InRecordErrorFile

Description:


InRecordErrorFile parameter definines a file path, where the records, whose processing didn’t run successfully, should be saved. They are in the input form in this file. Program MarcMan actually assorts the input records to the well converted ones and to those that were converted badly.

Obligation:

Obligatory for the batch processing mode, it is not meaningful for the client/server mode.

Notes:

Attention! – the file is overwritten at each convertor's initiation

Attention! - each directory must be separated by / (slash) sign in the file and directory paths, whatever the operating system is.

Example:

InRecordErrorFile=out/vystup_inerr.txt


InRecordOKFile

Description:


InRecordOkFile parameter defines a file path, where the records, whose processing did run successfully, should be saved. They are in the input form in this file. Program MarcMan actually assorts the input records to the well converted ones and to those that were converted badly.

Obligation:

Obligatory for the batch processing mode, it is not meaningful for the client/server mode.

Notes:

Attention! – the file is overwritten at each convertor's initiation

Attention! - each directory must be separated by / (slash)sign in the file and directory paths, whatever the operating system is.

Example:

InRecordOKFile=out/vystup_inOK.txt


IDAlephCoding

Description:

IDAlephCoding parameter is useful only for aleph format. It is a necessary character, that is used to determine a coding in the aleph record. More in Aleph formatchapter.

Obligation:

Obligatory for batch processing mode provided there is an aleph option in the DestinationFormatparameter.

Notes:

Attention! – the file is overwritten at each convertor's initiation

Attention! - this parameter is necessary to indicate provided it is specified as the output format of Aleph 500 system in DestinationFormatparameter.

Example:

IDAlephCoding=L

RulesFile

Description:


RulesFile parameter defines a path to the file, where the record processing rules are defined.

CodeFile parameter decides, whether it is coded rules file or uncoded file.

Obligation:

Obligatory for both processing modes.

Notes:

Attention! - each directory must be separated by / (slash) sign in the file and directory paths, whatever the operating system is.

Attention! - even if you have a light version, you have to set CodeFile parameter to" Yes".

Attention! – directory paths have to end by / (slash) sign.

Example:

RulesFile=modules/c_marc21_unimarc/conversion.rul

RulesFile=modules/c_marc21_unimarc/conversion.crul (for light version)


CodeFile

Description:


CodeFile parameter determines whether there is a path to the coded or uncoded rules file, defined in the RulesFileparameter . Possible values are "Yes" or "No".

Admissible values

  • Yes

  • No

Obligation:

Parameter doesn't have to be indicated. Then it means, it is an uncoded rules file.

Notes:

Attention! - even if you have a light version, you have to set CodeFile parameter to" Yes".

Example:

CodeFile=Yes


TablesDirectory

Description:


TablesDirectory parameter defines a path to the directory, where tables, required by the record processing rules, are saved.

Obligation:

Optional for both processing modes.

Notes:

Attention! - each directory must be separated by / (slash) sign in the file and directory paths, whatever the operating system is.

Attention! – directory paths have to end by / (slash) sign.

Example:

TablesDirectory=modules/c_marc21_unimarc/tbl/


LogFile

Description:


LogFile parameter defines a path to the file, where the information about the records processing course should be saved to.

Obligation:

Optional for the batch processing mode, it is not meaningful for the client/server mode.

Notes:

Attention! – the file is overwritten at each convertor's initiation.

Attention! - each directory must be separated by / (slash) sign in the file and directory paths, whatever the operating system is.

Attention! – directory paths have to end by / (slash) sign.

Example:

LogFile=out/convert_log.txt



EnableLogAll

Description:


EnableLogAll parameter defines a detail level of information relating to the processing course, which should be saved to the file determined by LogFile parameter.

If the parameter is set to Yes value, information detail about the processing course is very high. In this printing you can find a detailed description of all running operations, call functions in the rules etc.

If it is set to No value or is not set at all, detail level of information relating to the processing course is lower.

Admissible values:

  • Yes

  • No

Obligation:

Optional for the batch processing mode, it is not meaningful for the client/server mode.

Notes:

Attention!on any account, don’t initiate a large batch of records, the log file size then hugely rises and the conversion is slow.

Example:

EnableLogAll=No


ControlFile

Description:


ControlFile parameter defines a path to the file, which should be used for record control before the conversion. For more control module information, please see Record control chapter. File has ctr suffix.

Obligation:

Optional for the batch processing mode.

Notes:

Example:

ControlFile=modules/c_marc21_unimarc/marc21.ctr


PluginsDirectory

Description:


PluginsDirectory parameter defines a path to the directory, where the shared libraries (plugins) are saved to, broadening the covertor's options. Value of this parameter is added to the beginning of all paths indicated in the Pluginsparameter, if it’s defined.

Obligation:

Optional for both processing modes.

Notes:

Attention! - each directory must be separated by / (slash) sign in the file and directory paths, whatever the operating system is.

Attention! – directory paths have to end by / (slash) sign.

Example:

PluginsDirectory=marcman/plugins/


Plugins

Description:


Plugins parameter defines a path to the directory, where the shared libraries (plugins) are saved to, broadening the convertor's options.

Each path is separated by , (comma) sign. Value of PluginsDirectory parameter is added to the beginning of all indicated paths, if it’s defined.

Obligation:

Optional for both processing modes.

Notes:

Attention! - each directory must be separated by / (slash) sign in the file and directory paths, whatever the operating system is.

Attention! – directory paths have to end by / (slash) sign.

If this parameter is not indicated, plugins mechanism is automatically switching off (which means, that it is not possible to use particular extension in the rules, but the convertor is functioning with all basic features that it has at disposal).

Attention! - shared libraries suffixes vary according to the operating system type ( .so suffix is used on the unix type platform, whereas .dll suffix is used on the MS Windows platform)

Example:

Plugins=plugin_md5.dll,plugin_unicode.dll


4. Error message

Number of errors can occur at the process of the file opening , even at the conversion. All of the errors appear either on the command prompt or in the Log file. Even if the record conversin doesn't turn out well, the program continues with the conversion of the next record, it won't create a badly converted record in the DestinationFile, and saves the input record along with the error message into the InRecordErrorFile file.

5. Record formats

Current convertor’s version can process the following record formats:



a) ISO format

Description

Format of the data transmission file defined by ISO 2790 norm on the Library of Congress pages ( in english).

Definition

See ISO 2790 norm on the Library of Congress pages ( in english).


b) System Aleph 500 format

Description

This format is used by automatized library system Aleph 500 of Ex Libris group (representation for Czech and Slovak Republic). It is a proprieatary method of MARC’s records write into the text file. Apart from the standard MARC’s elements it also includes the information about internal definite record identification, and about field coding.


Definition

The record file in the Aleph 500 system format has a structure described below.


There is only one field indicated on each file line. The line consists of columns described in the following table:


Column description

Column format

Note

Record number

N(9)

C(1)

separating space

Field code inc.indicators

C(5)

C(1)

separating space

Coding

C(1)

constant L

C(1)

separating space

Field content

C(1,1992)


(letter C in the Column format indicates a text string, letter N number; number in the brackets indicates the column width, if they are two numbers separated by comma, it is minimum and maximum possible column width)


Individual records are not separated by a special separator. The first field, that begins with a record number different to a record number of the previous field, is considered as a beginning of the new record.


Example


000009484 FMT   L BK
000009484 LDR   L -----nam-a22--------4500
000009484 001   L cd000165
000009484 005   L 19981002000000.0
000009484 008   L 981002s1990----xr-----f------------cze--
000009484 020   L $$a(váz.)
000009484 040   L $$aABD157$$bcze
000009484 080   L $$a504$$2h
000009484 080   L $$a316.3$$2h
000009484 1001  L $$aStrázský, Václav$$4aut
000009484 24510 L $$aObčan a životní prostředí
000009484 260   L $$aPraha,$$c1990
000009484 300   L $$a37 s. :$$btab., +$$e64 tab.
000009484 502   L $$aZávěrečná práce PGS
000009484 65004 L $$aspolečnost
000009484 65004 L $$aživotní prostředí
000009484 7102  L $$aUniverzita Karlova v Praze.
000009484 BAS   L 23
000009484 BAS   L 36
000009484 CAT   L $$aXUZP$$b30$$c20030115$$lCKS01$$h0000
000009484 CAT   L $$c20041017$$lCKS01$$h2115
000009484 CAT   L $$aBATCH$$b00$$c20041106$$lCKS01$$h1034
000009484 CAT   L $$aBATCH$$b00$$c20041106$$lCKS01$$h1046
000009484 IAH   L $$lPGS 165$$g6177
000009484 910   L $$aABD157$$b6177


c) Text format



Description

Text format was created for the purpose of testing the record processing rules. Its main quality is better clarity in comparison with the previous formats, and it gives the user easier visual control over the output records and easier modification of the input records. The text format should be used only on one input and one output record at the testing process. It should not be used to save records at all.


Definition

In the text format the record file has a structure described below.


Each record in the file begins with a line including only @ (at-sign) – this sign can't be preceded or followed by either spaces or tabulators in the line. On the next line there is indicated 24 characters long record label. On each next line in the file, there is always only one record field indicated till the next appearance of the @ (at-sign), respectively till the end of file.


Line structure including the field is following. At the beginning of the line, there is always a code indicated followed by both indicators. If it is the field without one or both indicators, the spaces are indicated instead of the missing indicators. The field content itself begins behind the indicators. If the field content is divided into the subfields, each subfield begins with the symbol $ (dollar) followed by one letter determining particular subfield.


Example


@
nam 2200229 a 4500
001  zpk20010038759
005  20010110000000.0
008  $a010110s19989999 ger
020  $a3857921552 (2 Bände)
040  $aABD044$eAACR2
0410 $ager 044 $asz
080  $a581.9 24510$aFlora von Basel und Umberbung
260  $aBasel :$bNatursforschende Gesellschaft
300  $aS. 546-1003.
440 0$aMitteilungen der Naturforschenden
65004$aflóra.
651 4$aBasilej (Švýcarsko)
651 4$aBasilej okolí (Švýcarsko)
7001 $aBrodtbeck, Thomas.$4aut


6. Record processing rules

Record processing rules determine, which operations with the input records should be performed. Thanks to the rules, it is possible for example to define a conversion of UNIMARC>MARC21 or MARC21->UNIMARC, to control record validation in a given format, to assort records to correctly categorized or not correctly categorized (according to own criteria). Rules are written in Usescriptlanguage. Usescript language is a simple, not procedural interpreted language, similar to BASIC language, with built-in support to manipulate with bibliographic records saved in th eformats derived from MARC format.



a) Rule file structure

In typical example, the record processing rules are saved into the files with .rul suffix. There could be any number of the rules indicated in the file. Rules have a following structure.

from->where { usescript language rule }


Where the meaning of each rule part is such:



  • from - is an expression determining the input record field (subfield, indicator) that should be processed through a given rule, this expression is written in form of: record access expressions

  • where - is an expression determinig the output record field (subfield, indicator), where a final value should be saved in, this expression is written in form of: record access expressions

  • usescript language rule - is a succession of the usescript language expressions and commands defining how the value of the field resp.subfield should be processed


Example:


100$a->200$b { }


Constructions of from and where are written in form of record access expressions.

There should be signs "->" between them, otherwise the error is reported at the program initiation. You can write the usescript language scripts between the curly brackets. Example of full commentated rule could look like this:


207I2->362I1 {
	If S==" " Then S="1"
}


Rule can also be empty - that means, that value is transferred without a change to where.

Don‘t forget, that at the process of the conversion the rules are not performed successively as they are shown in the file .rul, but are performed one after another according to the form of the converted record. The program controls the field in the record in the following order:


  • Label (all rules starting with LAB are performed)

  • 1. Indicator of the field

  • 2. Indicator of the field

  • (at all subfields of the field) conversion of the subfield

  • (at all subfields of the field) conversion of 1. Indicator of the inserted field

  • (at all subfields of the field) conversion of 2. Indicator of the inserted field


The only quaranteed field order is such that the conversion of the indicators of the specific field is done before the conversion of the subfields of that particular field itself.  

If you then want to save some data for the conversion of the whole field, the best place is the rule for one of the indicators.

Four special rules exist as such:

Comments

Apart from the rules, it is also possible to save comments into the file.


We can make comments within the rules file, or we can also make comments directly in the individual rules. Each method has got a different mechanism:


Commenting inside the rule

There are two possible ways how to insert a comment. One line comments start with a sign ' (apostroph) - whole text in the line behind this sign is interpreted as a commentary.


Example:


100$a->200$b {
 	' empty rule 
}



Commenting within the rules file

The comment is necessary to place between signs /* (slash and star) and */ (star and slash). It is possible to place even multiple lined comments between those signs. In this case, it is necessary to comment a whole rule as one piece!

/*
	group of rules fro conversion field 100
*/

100$a->200$b {
 	' empty rule
}
/* commented rule
100$b->200$c {
 	' Toto pravidlo funguje 
}*/


Attention! - the comments can't cross or overlap each other.



b) Record access expressions



Rules to access the indicators of the fields, subfields and inserted fields

If you write the rules, you have to somehow indicate which field (subfield, indicator, inserted field) you want to work with. This is done through the expression, whose the most complicated form can be as followed:


423(1)L200$a(2)/1-5/

That means, you want to work with the first occurence of the 423 field, specifically with the second subfield $a of its inserted subfield 200. You want to work only with its first five symbols. Let's show another simple examples:

100$a

I want to work with all subfields $a in all fields 100

100(1)$a

I want to work with all subfields $a in all fields 100

100$a(3)

I want to work only with third subfield $a of all fields 100


100I1

I want to work with first indicator of all subfields 100


100I2

I want to work with second indicator of all subfields 100


LAB/1-3/

I want to work with first three characters (from first to third character)of the label


423L100I1

I want to work with first indicator of the inserted subfield 100 of all fields 423


100$a/2-5/

I want to work with second to fifth character of all subfields $a of all fields 100

And now only:

423(1)L200$a(2)/1-5/

That means, that you want to work with 423 field (specifically with the first one) and with second subfield $a of its inserted subfield 200. You want to work only with its first five characters.


Program MarcMan expects that every field has got a subfield. If the field doesn't have any subfield, MarcMan considers him as a special subfield $E. If you then want to work with a string in the field "001 zpk20010038759" you approach it:

001$E


Another speciality that you can encounter in the rules is for example a rule. All means, that at the beginning of the rule it is not clear , where the result will be leading to, and it would be then only confusing to write any expression here. Then in this rule the variable TOC has to be changed, otherwise the error occurs at the conversion.



207I2->All {        
    'change value of TOC
}



Special rules

It is possible to use some of the special rules in the rules.


BeforeAll->BeforeAll { some script }

Before->Before { some script }

After->After { some script }

AfterAll->AfterAll { some script }


Rule BeforeAll is performed even before the conversion of the whole package of the records. There is then no record accessible. All rules Before are performed before the record conversion and all rules After after the record conversion (you can assort the subfields here etc.).Rule AfterAll is performed after the conversion of the whole package of the records. They are not classical rules, therefore there is no standard collection of variablesas it is at other rules. The only possibility how to modify the record is through functions: SetValue.



Multiple rules (construction GROUP)

If you want to use the same rule for the multiple item conversion, you can write more expressions (from) and more expressions (where) separated by comma. The number of (from) and (where) expressions must be the same, otherwise the program reports an error. For example:


207I2,209I2->362I1,822I2 
{        
    If S=="" Then S="1"  
}


We can have a situation, where we can have a large number of such separated items. For this purpose you can use a macro construction GROUP(variable). Variable has to be global and has to be put either in theconfiguration file or in rule BeforeAll. This valuable has to contain the strings separated by comma. The (from) and (where) expressions will unroll according to these strings. For example:


Following will be indicated in BeforeAll rule:


MY_FROM=700,701,702,703,704 
MY_TO=400,401,402,456,480


Following rule will be indicated in the rules file :


/*Multiple rule*/
GROUP(MY_FROM)$a->GROUP(MY_TO)$a { 

}


It is the same as if you write:

/*Multiple rule*/
700$a,701$a,702$a,703$a,704$a->400$a,401$a,402$a,456$a,480$a  { 

}


You can use the group in more rules and you don't have to write it all the time:


c) UseScript Language

Rule language was proposed with a view to create the most simple syntax. That's why, it takes from the syntax of Basic language, however, some of the elements are taken over from other programming languages. It only has a basic collection of operators and control structures, neccessary to write the simple rules. Its features are following:


  • It is not possible to define own functions in the program.

  • Language has only two data types. Integer type and String type.

  • Language identifines the types dynamically. That means, you don't have to set the type of the variable.

  • Language belongs to the interpreted language group, no translation is carried out then.

  • Before using the variables, they are necessary to be initialized by some value. That means, that the first variable occurence has to always be on the left side of the assignment command.

  • Language works internally with the Integer type from C language, Integer value can be then in the particular range.

  • Comments are put behind the single quote ' sign and everything from this to line end is a comment. Multiple line comments are not supported by the language.

  • UseScript language is case sensitive, which means, that it depends if you write While or WHILE or while. Only first example is correct and anything else will be considered as an error. The variables work the same way. Variable Moje and variable MOJE are two different variables.



Key words

The following table shows a list of the key words of the usescript language. They are reserved words, that are not possible to use as variable names and which correspond with the elementary commands of the usescript language for program run control.


  • If

  • Then

  • Else

  • Endif

  • While

  • Wend

  • For

  • To

  • Next

  • Exit


Operators


Usescript language define these operators with the evaluation priorites mentioned below:


Operator

Symbol

Description

Priority

*

star

multiplication

5

/

slash

dividing

5

+

plus

adding

4

-

minus

subtraction

4

==

pair of equal signs

equals?

3

!=

exclamation mark and equal sign

does't equal?

3

>

většítko

greater than?

2

<

menšítko

less than?

2

&

ampersand

connective AND

1

|

so called "pipe"

connective OR

1


Priority determines the evaluation order of the operators not in bracketed expression. The higher number indicated in the priority column is, the faster is that particular operator evaluated. Operators with the same priority are evaluated from left to right.


Example:


12*5+2


Numbers 12 and 5 (operator * with priority 5) are multiplied first, and then a number 2 (operator + with priority 4) is added to the intermediate result.


In order to process a total of number 5 and number 2 followed by a multiplication by number 12, it is necessary to write an expression as followed:


Example:


12*(5+2)


In case of logical conditions the situation is analogical. Condition:


Example:


a > 5 | a < -5


is evaluated hereby: first it is evaluated, whether a variable value is greater than 5, followed by an evalution whether a variable value is less than -5, and in the last step the following evalution is processed, whether a value of the operator's left argument | (pipe sign) is true, and if not, then it is evaluated, whether a value of the right argument is true.


Attention! - usescript language doesn't use the shortened evalution of the condition with a connective OR - that means, that the right argument of the operator | (so called. "pipe") is evaluated always.



Control structures


The following review shows the Usescript language basic commands, that are used for the program run control.


If

Write:

If condition Then command [Else command]

Description:

Conditional command.

If the condition shown between the key words If and Then is fulfilled, the commands shown between the words Then and Else resp. Endif are processed; in the opposite case, the commands shown between the words Else and Endif are processed. Else Construction doesn't have to be indicated in the conditional command.

Examples:

Example of the write without a word Else:


If a>10 Then
	WriteToLog("a is greater then ten")
Endif


Example of full condition write:


If a>10 Then
   WriteToLog("a is greater then ten")
Else
   WriteToLog("a is less then or equal ten") 
Endif


Example of shortened write of the one line conditional command. It is possible to write a command on one line only if there is only one command behind Then resp. Else. Example:


If a>10 Then WriteToLog("a is greater then ten")

For

Write:

For control variable = initial value To target value

commands

Next

Description:

Iterative command. Commands indicated between the lines including words For and Next are processed in the cycle. At each cycle the control variable with the initial value "initial value" increases by one, till it reaches the "target value" value shown behind the key word To. When the control variable reaches the target value, the last cycle is processed and the performance of the command ends up.

Examples:

Example of value variables write of the interval 1 to 10 into the log file:


For i=1 To 10
	WriteToLog("i=" + i)
Next


Record of the performed example indicated in the log file above would be as such:


i=1
i=2
i=3
i=4
i=5
i=6
i=7
i=8
i=9
i=10

While

Write:

While condition

commands

Wend

Description:

Cycle with the condition at the beginning. Commands between the lines including While and Wend are processed in the cycle till the condition indicated behind the key word While is fulfilled.

Examples:

Example of a value variables write of the interval 1 to 10 into the log file:


i=0
While i<11
   i=i+1
   WriteToLog("i=" + i)
Wend 


Record of the performed example indicated in the log file above would be as such:


i=1
i=2
i=3
i=4
i=5
i=6
i=7
i=8
i=9
i=10

Exit

Write:

Exit

Description:

Command to end the script performance.

Examples:

Example of a variable value write of the interval 1 to 10 into the log file ending after the first iteration:


i=0
While i<11
	i=i+1
	WriteToLog("i=" + i)
	Exit
Wend


Record of the performed example indicated in the log file above would be as such:


i=1

Notes:

Attention! - command must be indicated on the separated line, it is not possible to indicate it e.g. in shortened form of command write If.

Variables

1. Variables defined by user

Variable can be imagined as something like a defined disposal site. Here you can store number or text in the usescript language.

If we want to save something into the variable, first it is necessary to choose its name and then to insert the value into it through the assignment command = (equal sign).

Command:

a=10


thus causes, that number 10 is saved into a variable a. If we use variable in an expression, that particular value is used instead of the variable name, in this case it is number 10.


Command:


b=a+10


thus causes, that number 20 is saved into the variable (thus 10 + 10).


It is possible to selet a variable name any time, if the name consists of alphanumerical and underscore characters, and doesn't collide with the usescript language key words. It is useful to name the variables in such a way, the variable name corresponds with the meaning of the saved value.


Text strings can also be saved into the variable.


Command:


author_name="Milne, A.A."


thus causes, that a text string "Milne, A.A." is saved into the variable nazev_autora.


To keep it simple, the variables are saved into the one repository of variables. That means, that if you define a variable in one rule, that variable will be present in any other rule, even at the conversion of the next record!!!!


2. Predefined variables

Some of the variables are initialized before performing any particular rule. This chapter describes their meaning and usage. These variables are possible to modify in the rule, and therefore to influence the conduct of the program.


1. Variable S

Value of currently processed item is in variable "S" and after the performing the rule, the value from this particular variable is inserted into the predefined output item.

Example:


200$a->300$b  {      
        WriteToLog(S)           
	S="test" + S            
}


That means, if the rule is empty (200$a->300$b{ }), value S is transmitted without a change, and 300$band field will contain the same as 200$a field contained.


2. Variable TOC

String of the rule behind the arrow is saved into the variable TOC, so in case of 200$a->300$b{ }, "300$b" is saved here, and if you change this in the course of performing the rule, the output in the variable S will be directed somewhere else. For example:


200$a->300$b  {      
        TOC="300$c"         
}


it is the same as if you write:


200$a->300$c  {      

}


This way you can change dynamically the target of the resultunt value at the course of the rule performance. If the value is changed in the rule, the rule should look like as follows:


200$a->All  {      
        TOC="300$c"         
}


Value All says to the reader of the rules, that variable TOC is modified in the rule, and therefore it is indifferent what an expression has on the right side behind the arrow.


3. Variable FROMC

The string of the rule before the arrow is saved in the variable FROMC, thus in case of 200$a->300$b{ } it is saved 200$b. It is variable read only - which means, that you won't get anywhere by changing its value.

4. Variable FROM_IDF

Part of the variable FROMC is saved in the variable FROM_IDF , specifically the first three characters (Mid(FROMC,1,3)). This part, generally indicating the field name (in 200$a it is string "200"), is used so often, that the new variable was created in order not to use the construction shown in the brackets.


5. Variable SET

Variable SET has default value of 1, if you change it to zero, that means, nothing will be set after completing this rule. Which means, that values S and TOC come to nothing.


6. Variable ADD

Variable ADD has default value of 0, if you set it to one, that means, you don't want to replace a value in the current output, but to add a variable S to the current value.


7. Variables NF,NS

Variables NF, NS are probably the most complicated part of the conversion. They solve the situation, where for example there is a repeatable field in the input format, but a field, where values are directed to, is not repeatable, and values from many input subfields are piling up in one single output field:


That is different to the situation, when at every new field 200 a new output field 100 would be created. You can modify this conduct by setting the values NF(Number field), NS(NumberSubfield). These are basically the index values, similarily as it is in the expressions of 200(1)$a(3) type.

The variables NF,NS are input and as well as the output values, similarily to a variable S, which is input as well as output value.


Let's have a record:


200  $afirst value
200  $asecond value
200  $athird value


and rule


200$a->100$a { WriteToLog("NF:" + NF + " - NS:" + NS) }


There is an index of currently processing field in NF variable at the input. (in our case, variable would contain successively 1,2,3 and in three cases the NS would be 1 ($a is always alone and first). From the rule indicated above there would be three lines in the log file.


NF:1 - NS:1 
NF:2 - NS:1 
NF:3 - NS:1


Output would then be directed into the field 100(NF)$a(NS) thus successively till:


100(1)$a(1)
100(2)$a(1)
100(3)$a(1) 


As there was no 100 field before processing of the rule, three new fields with index 1-3 would be created successively. This is a standard behaviour. If you want to change this behaviour in order to have the situation as it is in the picture, your rule would look as follows:


200$a->100$a { NS=NF; NF=1 }


Output would then be directed into a field 100(NF)$a(NS) thus successively to:


100(1)$a(1) 
100(1)$a(2)  
100(1)$a(3)


Only one field 100 with three subfields $a would be created. If you want that all subfields $a would combine into one single subfield $a of one single subfield $100, you would proceed as followed:


200$a->100$a { NS=1; NF=1; ADD=1 }


The result would be


100$afirst valuesecond valuethird value



Functions


Apart from the control structures, there is a set of functions in the usescript language. These functions are described in this chapter.


Alphabetical list of functions:



Attention! - Usescript language doesn't support a definition of own functions at this moment.


1. Trimming functions
WriteToLog

Description:

Function writes a line "value" into a log file

Call example:

WriteToLog(value)

Input arguments:

Designation

Data type

Note

value

text string or numeric value

any text string or numeric value

Return value:

-

Example:

WriteToLog("i=" + i)


Execution of the example indicated above causes a printing of the variable value also in the log file.

GetRecord

Description:

GetRecord returs the output, thus rising record into a format txt. You can find more information on this format in chapter Text format

Call example:

GetRecord()

Return value:

Record in txt format.

Example:

In case of such output record


nam 2200229 a 4500
001  zpk20010038759
005  20010110000000.0
260  $aBasel :$bNatursforschende Gesellschaft
7001 $aBrodtbeck, Thomas.$4aut
7001 $aBrodtbeck, Thomas.$4aut


command would


WriteToLog("*******************************")
WriteToLog(GetRecord())
WriteToLog("*******************************")


cause a printing into a log file:


*******************************
nam 2200229 a 4500
001  zpk20010038759
005  20010110000000.0
260  $aBasel :$bNatursforschende Gesellschaft
7001 $aBrodtbeck, Thomas.$4aut
7001 $aBrodtbeck, Thomas.$4aut
*******************************


2. Functions to work with the files
ClearFile

Description:

Function serves for reducing the file with a set name to zero size. If the file still doesn't exist, empty file with set name is created.

Call example:

ClearFile(file name)

Input arguments:

Designation

Data type

Note

file name

text string

file name, which should be reduced to zero size, file doesn't have to exist

Attention! - convertor has to have a right to create such a file resp. to write into it

Return value:

Return value is 0, if the file reduction was processed successfully; otherwise the error message is printed out into a log file about an impossibility to process a record reduction operation.

Example:

ClearFile("/tmp/outrecord.txt")


Execution of the example mentioned above causes a file reduction /tmp/outrecord.txt to zero size.

WriteOutRecordToFile

Description:

Function serves for calling the immediate write of the input record including possible already processed modifications to the file in a given format. If the file stil doesn't exist, it is created by calling up this function. If it does exist, the write out record is added to the end of the file.

Call example:

WriteOutRecordToFile(file name,record format)

Input arguments:

Designation

Data type

Note

file name

text string

file name, where record should be written, file doesn't have to exist

Attention! - convertor has to have right to create such a record resp. to write into it

record format

text string

these are only admissible values: aleph, iso and txt (More on record formats,see record formats)

Return value:

Return value is 0, if the file reduction was processed successfully; otherwise the error message is printed out into a log file about an impossibility to process a write operation.

Example:

WriteOutRecordToFile("/tmp/outrecord.txt","txt")


Execution of the example mentioned above causes immediate write of output record including possible already processed modifications into a file /tmp/outrecord.txt in text format.

3. Functions to work with strings
TranslateAsciiChars

Description:

Function translates all character occurences in a set input text string, character by character, from a source character set into a target character set.

Call example:

TranslateAsciiChars(text,source character set, target character set)

Input arguments:

Designation

Data type

Note

text

text string

any text string; if text string is not an argument, error message prints out into a log file

source character set

textový řetězec

Attention! - only ASCII characters can be set, and their number must corresponds with a number of characters in argument - target character set

target character set

text string

Attention! - only ASCII characters can be set, and their number must corresponds with a number of characters in argument - source character set

Return value:

Return value is a requested input text string, where all character occurences from source character set are replaced with the corresponding characters from target character set.

Example:

t = TranslateAsciiChars("male","elma","ELMA")
WriteToLog("male -> "+t)


Execution record of an example indicated above in the log file would look like as follows:

male -> MALE

StripAsciiChars

Description:

Function removes (strips) from requested input text string, all character occurences, from a particular character set, resp. removes characters that are not indicated in the requested character set.

Call example:

StripAsciiChars(text,character set,complement)

Input arguments:

Designation

Data type

Note

text

text string

any text string; if a text string is not an argument, error message prints out into a log file

character set

text string

Attention! - only ASCII characters can be set

target character set

number

Attention! - only value 1 or 0 can be set, if another value is indicated, nothing will be changed in the input text string;


if value is set to 0, all characters indicated in that character set are removed from the input string.


if value is set to 1, the complement to that character set is removed from the input string, thus not indicated characters in that set.

Return value:

Return value is a requested input string, where all character occurrences from source character set are substituted by the corresponding characters from the target character set.

Example:

t = StripAsciiChars("i n t e r l a c e d - t e x t"," ",0)
WriteToLog("text= "+t)


Execution record of an example indicated above in the log file would look like as follows:


text = interlaced-text


Similarily:


t = StripAsciiChars(".0a9de8f7g6ty5j4k3ad2a","0123456789",1)
WriteToLog("numbers only= "+t)


Execution record of an example indicated above in the log file would look like as follows:


numbers only = 0987654321


Mid

Description:

Function returns a part of the string beginning with start, of length length.

Call example:

Mid(string, start, length) or Mid(string, start)

Input arguments:

Designation

Data type

Note

string

text string

any text string; if a text string is not an argument, error message prints out into a log file

start

number

start of the string part.Value would be 1 for first word.

[length]

number

Optional parameter. If you don't indicate the parameter, the returned part will be from start argument to the string end.

Return value:

Return value is a corresponding string part.

Example:

WriteToLog("short text = " + Mid("something text",3,3))


Execution of the example indicated above writes a following text into a log file:


short text = som


Len

Description:

Function returns a length of the string.

Call example:

Len(string)

Input arguments:

Designation

Data type

Note

string

text string

any text string; if a text string is not an argument, error message prints out into a log file

Return value:

Return value is the length of the string as a number.

Example:

WriteToLog("length of text = " + Len("something text"))


Execution of the example indicated above writes a following text into a log file:


length of text = 14


Find

Description:

Function finds a substring in the string and returns a position of the fist substring occurence either from the string start or from the start position.

Call example:

Find(string, substring, start) or Find(string, substring)

Input arguments:

Designation

Data type

Note

string

text string

any text string; if a text string is not an argument, error message prints out into a log file

substring

text string

any string, which should be found in the string, requested as a first argument

[start]

number

position in the string string, where the find of the substring string should start

Return value:

Return value is a number - occurence position counted from 1.

Example:

WriteToLog("Position=" + Find("something text text","te"))


Execution of the example indicated above writes a following text into a log file:


Pozice=11



FindReverse

Description:

Function finds a substring in the string reversely and returns a position of the first substring occurence either from the string end or from the start position.

Call example:

FindReverse(string, substring, start) or FindReverse(string, substring)

Input arguments:

Designation

Data type

Note

string

text string

any text string; if a text string is not an argument, error message prints out into a log file

substring

text string

any string that should be found in the string, set as a first argument of the reverse search.

[start]

number

position in the string string, where the find of the substring string should start

Return value:

Return value is a number - occurence position counted from 1.

Example:

WriteToLog("Position=" +FindReverse("something text text","te"))

Execution of the example indicated above writes a following text into a log file:


Position=16

Trim

Description:

Function trims (removes) the string spaces, from the right and from left. It doesn't trim (remove) the spaces, which are inside the text.

Call example:

Trim(string)

Input arguments:

Designation

Data type

Note

string

text string

any text string; if a text string is not an argument , error message prints out into a log file

Return value:

Return value is a string with no spaces from the right and left.

Example:

WriteToLog("<" +Trim("   something text ") + ">")


Execution of the example indicated above writes a following text into a log file:


<something text>


TrimChars

Description:

Function trims the characters from the string, from right and left, that are in the character group. It doesn't trim the characters that are inside the text, which doesn't start nor end by any of the characters in the character group.

Call example:

TrimChars(string, character group)

Input arguments:

Designation

Data type

Note

string

text string

any text string; if a text string is not an argument, error message prints out into a log file

character group

text string

character group, which should be removed from the string start and end. That means, the character group,which contains any number of character occurences from this parameter, will be removed from the string start and end.

Return value:

Return value is a string with no spaces from right and left.

Example:

WriteToLog("<"+TrimChars(";(( t-ext,a ,,/",",()/;: -")+">")

Execution of the example indicated above writes a following text into a log file:


<t-ext,a>


Replace

Description:

Function scans the string and all substring occurences replaces with replacement text

Call example:

Replace(string, substring, replacement)

Input arguments:

Designation

Data type

Note

string

text string

any text string

substring

text string

any text string, which should be found in the string set as first argument, and replaced with the third argument

replacement

text string

any text string,which should replace a string, set as second argument

Return value:

Return value is a string.

Example:

WriteToLog("Rewritten = " + Replace("this text","te","---"))


Execution of the example indicated above writes a following text into a log file:


Přepsaný = this ---xt


SplitByChars

Description:

Function splits the string into the value arrays, which are separated in the string by one of the separator array elements. The result will appear in the array called array name, and in the array called separator array name they are indicated separators, which separated individual values. Method determines how the separation should be performed.

Call example:

SplitByChars(string, separators, array name, separator array name, method)

Input arguments:

Designation

Data type

Note

string

text string

any text string

separators

text string

array including separators

array name

text string

array name, that still doesn't have to exist,and where you find separated individiual values, after the command execution.

Separator array name

text string

array name,that still doesn't have to exist, and where, after the command execution, you find the separators,by which the string was separated as they appeared one after another.

method

text string

Might have following values:

  • "BYALL"

    in the string, the separators don't have to go successivelly,as they are indicated in the separator arrray

  • "BYORDER"

    in the string, the separators must go successively as theyappear in the separator array, but some of them can be omitted

  • "BYORDERDIRECT"

    in the string, the separators must go successively as theyappear in the separator array, none can be omitted

Re-entry value:

One if command run successfuly or zero in the opposite case.

Example:

In this input record:


nam 2200229 a 4500
001  zpk20010038759
005  20010110000000.0
260  $aBondy, Egon ; writer (dramatist)
7001 $aBrodtbeck, Thomas.$4aut
7001 $aBrodtbeck, Thomas.$4aut



And in this rule:


260$a->All {
   Array("Separators" , "," , " ; " , "(" , ")") 
   If SplitByChars( S , "Separators" , "Hodnoty" , "Znacky" ,
           "BYORDERDIRECT" )==0 Then
     WriteToLog("Chyba")
     Exit
   Endif
   For i=1 To CountArray("Hodnoty")
   WriteToLog("Hodnota: " + GetArray("Hodnoty",i) + 
           "- Oddělovač: " + GetArray("Znacky",i)) 
Next 


The result would be in the log file as such:


Hodnota: Bondy - Oddělovač: ,
Hodnota: Egon - Oddělovač:  ; 
Hodnota: writer - Oddělovač:  ( 
Hodnota: dramatist - Oddělovač:  ) 


4. Conversion functions
Table

Description:

Function opens a table saved in the file of the particular name, and finds there a value corresponding with the indicator.

File structure defining a table is the same as the file structure with the convertor's parameters, and the rules for the indicator write are the same as the rules for the parameter write. (see Configuration file structure)

Call example:

Table(file name,indicator, alternative return value) or Table(file name, indicator)

Input arguments:

Designation

Data type

Note

file name

text string

any text string; if a text string is not an argument, error message prints out into a log file


Attention! - field with a particular name has to already exist in the directory TablesDirectory (see convertor parameter TablesDirectory)

indicator name

text string

indicator whose corresponding value should be found in the table

[alternative return value]

text string

optional argument

any text string, which should be returned, if the indicator is not found in the table

Return value:

Return value is either an indicator value found in requested table, or a value of the third argument; if the indicator was not found in the table, if the third argument is not indicated and the indicator was not found, the return value is a string consisting of letters "X" of same length that requested indicator has.

Example:

If there is a file den.tbl in the directory specified by parameter TablesDirectory, containing:


1=Monday
2=Tuesday
3=Wednesday
4=Thursday
5=Friday
6=Saturday
7=Sunday


Then the execution of the following example:


t = Table("day.tbl","1","not found")
WriteToLog("day = "+t)
t = Table("day.tbl","8","not found")
WriteToLog("den = "+t)


would cause, that the record would appear in the log file as follows:


day = Monday
day = not found


GetMarcInValue

Description:

Function returns a value that is in line with a command in the current record at the input. Command requires the same syntax, which is used for writing the rules. You can find more information on how to write those rules in the chapter Record access expressions. e.g. command types:

GetMarcInValue("200(2)$a(1)")

Unlike the record access expressions, it is necessary to indicate field and subfield index in the rule letterheads. It needs to be clear then, which field or subfield you have in mind. For example if you call:

GetMarcInValue("200$a")

The program doesn't recognize, which 200 field and which $a subfield you have in mind.This procedure fails, eventhough there is only one field and its subfield in the record. It is necessary to indicate specifically:

GetMarcInValue("200(1)$a(1)")



Call example:

GetMarcInValue(expression)

Input arguments:

Designation

Data type

Note

expression

text string

text string in form of Record access expression

Return value:

Return value is an entity value, which you designated in the expression. If your expression is wrong or particular entity was not found, function returns an empty string.

Example:

In this output record:


nam 2200229 a 4500
001  zpk20010038759
005  20010110000000.0
260  $aBasel :$bNatursforschende Gesellschaft
7001 $aBrodtbeck, Thomas.$4aut


following example would:


WriteToLog("value  = " + GetMarcInValue("260(1)$a(1)"))


cause a writing of the following text into a log file:

value = Basel :


and following


WriteToLog("value = " + GetMarcInValue("700(1)I1"))


would cause a writing of the following text into a log file:


value = 1


GetMarcOutValue

Description:

Function returns a value that is in accordance with a command in the current record at the output (it is record that is being created at the conversion process). Command requires the same syntax, which is used for writing the rules.You can find more information on how to write those rules in the chapter Record access expressions.

Expression types:

GetMarcOutValue("200(2)$a(1)")

Unlike the record access expressions , it is necessary to indicate field and subfield index in the rule letter heads . It needs to be clear then, which field or subfield you have in mind. For example if you call:

GetMarcOutValue("200$a")

The program doesn't recognize, which 200 field and which $a subfield you have in mind. This procedure fails, eventhough there is only one field and its subfield in the record. It is necessary to indicate specifically:

GetMarcOutValue("200(1)$a(1)")



Call example:

GetMarcOutValue(expression)

Input arguments:

Designation

Data type

Note

expression

text string

text string in form of Record access expressions

Return value:

Return value is an entity value, which you designated in the expression. If your expression is wrong and requested entity was not found, function returns an empty string.

Example:

In this output record:


nam 2200229 a 4500
001  zpk20010038759
005  20010110000000.0
260  $aBasel :$bNatursforschende Gesellschaft
7001 $aBrodtbeck, Thomas.$4aut


following command would:


WriteToLog("value = " + GetMarcOutValue("260(1)$a(1)"))


cause a writing of the following text into the log file:


value = Basel :


and following:


WriteToLog("value = " + GetMarcOutValue("700(1)I1"))


would cause a writing of the following text into the log file:


value = 1


MaxI

Description:

Function returns a maximum command index at the input. Command requires the same syntax, which is used for writing the rules.You can find more information on how to write those rules in the chapter Record access expressions.


Command types:

MaxI("200(1)$a")

Unlike the record access expressions, requested entity index can't be indicated in the rule letterheads. At the same time, there is no point in requesting an indicator index, to indicate a construction of the entity parts in the curly brackets, and the like. Admissible commands would for example be:

MaxI("200")

or

MaxI("200(1)$a")

but not

MaxI("200$a")

as it is not clear, which 200 field you have in mind.

And also not

MaxI("200(1)$a(1)")

as in this case there is nothing to count.

Call example:

MaxI(expression)

Input arguments:

Designation

Data type

Note

expression

text string

text string in form of Record access expressions

Return value:

Return value is a number, that indicates an entity number, requested in the your command.

Example:

In this input record:


nam 2200229 a 4500
001  zpk20010038759
005  20010110000000.0
260  $aBasel :$bNatursforschende Gesellschaft
7001 $aBrodtbeck, Thomas.$4aut
7001 $aBrodtbeck, Thomas.$4aut


following command would:


WriteToLog("count = " + MaxI("260(1)$a"))


cause writing of the following text into the log file:


count = 1


and following


WriteToLog("count = " + MaxI("700"))


would cause a writing of the following text into the log file:


count = 2


MaxO

Description:

Function returns a maximum command index at the output. (it is record that is being created at the conversion process). Command requires the same syntax, which is used for writing the rules.You can find more information on how to write those rules in the chapter Record access expressions.


Command types:

MaxO("200(1)$a")

Unlike the record access expressions, requested entity index can't be indicated in the rule letterheads. At the same time, there is no point in requesting an indicator index, to indicate a construction of the entity parts in the curly brackets, and the like. Admissible commands would for example be

MaxO("200")

or

MaxO("200(1)$a")

but not

MaxO("200$a")

as it is not clear,which 200 field you have in mind.

And also not

MaxO("200(1)$a(1)")

as in this case there is nothing to count.

Call example:

MaxO(expression)

Input argumentys

Designation

Data type

Note

expression

text string

text string in form of Record access expressions

Return value:

Return value is a number, that indicates the entity number requested in your command.

Example:

In this output record:


nam 2200229 a 4500
001  zpk20010038759
005  20010110000000.0
260  $aBasel :$bNatursforschende Gesellschaft
7001 $aBrodtbeck, Thomas.$4aut
7001 $aBrodtbeck, Thomas.$4aut


following command would:


WriteToLog("count = " + MaxO("260(1)$a"))


cause writing of the following text into the log file:


count = 1


and following


WriteToLog("count = " + MaxO("700"))


cause writing of the following text into the log file:


count = 2


NeibField

Description:

Function examines the environment of the currently processed field in the input record, and returns a field name. Displacement determines, where to look in the environment.

For example at:


NeibField(-1)


it returns a field, which is the first before the currently processed field.

And at


NeibField(1)


it returns a field, which is the first after the currently processed field.


Call example:

NeibField(displacement)

Input arguments:

Designation

Data type

Note

displacement

number

Positive or negative number determining displacement

Return value:

If it doesn't find such, it returns an empty string.

Example:

In this input record:


nam 2200229 a 4500
001  zpk20010038759
005  20010110000000.0
260  $aBasel :$bNatursforschende Gesellschaft
7001 $aBrodtbeck, Thomas.$4aut
7001 $aBrodtbeck, Thomas.$4aut


following command would:


260$a->150$a {
   WriteToLog("before = " + NeibField(-1))
}


cause a writing of the following text into the log file:


before = 005


and following


700$a->150$a {
   WriteToLog("before = " + NeibField(-1))
}


would cause a writing of the following text into the log file:


before = 260
before = 700


NeibSubField

Description:

It examines the environment of the currently processed subfield in the input record, and returns a subfield name. Displacement determines, where to look in the environment.The function doesn't cross the field borders, which means, it only operates in the current field. For example at


NeibSubField(-1)


it returns a subfield, which is the first before the currently processed subfield, in the currently processed field.

And at


NeibField(1)


it returns a subfield,which is the first after the currently processed subfield, in the currently processed field.


Call example:

NeibSubField(displacement)

Input arguments:

Designation

Data type

Note

displacement

number

Positive or negative number determining displacement

Return value:

If it doesn't find such, it returns an empty string.

Example:

In this input record:

Following command would:


260$a->150$a {
   WriteToLog("after = " + NeibField(1))
}


cause a writing of the following text into the log file:


after = b


and following


700$4->150$a {
   WriteToLog("before = " + NeibField(-1))
}


cause a writing of the following text into the log file:


before = a
before = a


IsSubBefore

Description:

In the input record, it examines a subfield that is before the currently processed subfield in the currently processed field, and finds out, if there is a field with subfield name indicator.

Call example:

IsSubBefore(subfield name)

Input arguments:

Designation

Data type

Note

subfield name

text string of length 1.

subfield indentificator, that should be found

Return value:

It returns number 1, if there is a field with subfield name identificator, or 0 if there isn't.

Example:

In this input record:


nam 2200229 a 4500
001  zpk20010038759
005  20010110000000.0
260  $aBasel :$bNatursforschende Gesellschaft
7001 $aBrodtbeck, Thomas.$4aut
7001 $aBrodtbeck, Thomas.$4aut


following command would:


260$b->150$a {
   WriteToLog("a is before= " + IsSubBefore("a"))
}


cause writing of the following text into the log file:


a is before = 1


and following


700$4->150$a {
   WriteToLog("b is before = " + IsSubBefore("b"))
}


would cause writing of the following text into the log file:


b is before = 0
b is before = 0


SetValue

Description:

Function in the accordance with the command, in form ofRecord access expressions sets the value in newly formed thus in the output record. Value is an entity value, that should be set (analogy of variable S in the rule),field index is a field index, where a value should be directed to (analogy of variable NF in the rule), subfield index is a subfield index, where the value should be directed to (analogy of variable NS in the rule) and if add is set to 1, value will be added to the already existing value (analogy of variable ADD in the rule) If an index is zero, that means, similar to variables NF and NS, that a field, respectively subfield should be added, otherwise a field with the particular index and subfield with the particular index is retrieved, and value is either inserted into it (if add equals zero) or adds(if add equeals one).

This command is an alternative way, how to influence the output record in the rule. This way it is possible to create from one rule more outputs.


Call example:

SetValue(command, value, field index , subfield index, add)

Input arguments:

Designation

Data type

Note

command

text string

text string in form of Record access expressions

value

text string

setting value

field index

number

field index, where the value should be directed to

subfield index

number

subfield index, where the value should be directed to

add

number

if the current value should be overwritten or value added

Possible values

  • 0

  • 1

Return value:

-

Example:

In this input record:


001  zpk20010038759
005  20010110000000.0
260  $aBasel :$bNatursforschende Gesellschaft
7001 $aBrodtbeck, Thomas.$4aut
7001 $aBrodtbeck, Thomas.$4aut


After the following command:


260$b->All {
   SetValue("500$a","valueA",1,1,0)
   SetValue("500$b","valueB",1,1,0)
   SET=0
}


the output record would look like as follows:


001  zpk20010038759
005  20010110000000.0
500  $avalueA$bvalueB
7001 $aBrodtbeck, Thomas.$4aut
7001 $aBrodtbeck, Thomas.$4aut


Or after the following command:


260$b->All {
   SetValue("500I1","1",1,0,0)
   SetValue("500$a","valueA",1,1,0)
   SetValue("500$b","valueB",1,1,0)
   SetValue("500$a","valueA",1,1,1)
   SetValue("500$b","valueB",0,0,0)
   SET=0
}


the output record would look like as follows:


BreakError

Description:

This function breaks the conversion of the current record, the record is marked as faulty and along with the message, is handled as any other badly converted record. Then it continues with the conversion of the next record in the package. Record is saved into the file InRecordErrorFile and your message appears in the log file.

Call example:

BreakError(message)

Input arguments:

Designation

Data type

Note

message

text string

any text string including a problem message

Return value:

-

Example:

ContinueError

Description:

By this function the record is marked as faulty, nevertheless, the conversion of the current record doesn't break, record is marked as faulty and along with the message, is handled as any other badly converted record. Conversion continues as if no error occurred. Record is saved into the file InRecordErrorFile and your message appears in the log file. This function is used for example in detailed control of the record by the help of the rules. You can find more information on this control in the chapter Control file

Call example:

ContinueError(message)

Input arguments:

Designation

Data type

Note

message

text string

any text string including a problem message

Return value:

-

Example:

5. Auxiliary functions
GetMaxUnsignedInteger

Description:

Function returns largest integer value, that occurs in form of text string in the requested string. Any no numerical character is considered as a number separator. Sign - (which is minus) is interpreted also as a separator.

Call example:

GetMaxUnsignedInteger(text)

Input arguments:

Designation

Data type

Note

text

text string

any text string; if a text string is not an argument, the error message writes into the log file

Return value:

The largest integer occuring in form of the text string in the requested string , or empty string, in case there is no number in the requested string.

Example:

i = GetMaxUnsignedInteger("A10-11.20")
WriteToLog("i = "+GetString(i))


Execution record of an example indicated above in the log file would look like as follows:


i = 20

GetInteger

Description:

Function tries to convert a string into a number.

Call example:

GetInteger(text)

Input arguments:

Designation

Data type

Note

text

text string

any text string; if a text string is not an argument, the error message writes into the log file

Return value:

Either a number corresponding with a number in the text string, otherwise it returns zero.

Example:

Command


WriteToLog("suma = " + (GetInteger("125") + 3))


Execution of the example above in the log file would look like as follows:



suma = 128

GetString

Description:

Function converts a string into a number.

Call example:

GetString(number)

Input arguments:

Designation

Data type

Note

number

number

Return value:

Text corresponding with a number.

Example:

Command


WriteToLog("Number = " + GetString(5))


Execution of the example indicated above in the log file would look like as follows:


Number = 5


Which in this case, it is purposeless, as the automatic type conversion would do the same in the following example:


WriteToLog("Number = " + 5)


However, in this case:


i=200 
MaxI(GetString(i))


there would be a point.


Modulo

Description:

Function returns the remainder after dividing the number1 by number2

Call example:

Modulo(number1, number2)

Input arguments:

Designation

Data type

Note

number1

number

divident

number2

number

divisor

Return value:

Remainder after dividing number1 by number2.

Example:

Command


WriteToLog("modulo = " + Modulo(20,3))


Execution of the example indicated above in the log file would look like as follows:


modulo = 2


Array

Description:

Function creates a new array array name, with the elements element1 to elementN. Function has a variable number of parameters. First element is an array name and other elements are array elements ...

Call example:

Array(array name, element1,element2 ......)

Input arguments:

Designation

Data type

Note

array name

text string

any text string; if a text string is not an argument, the error message writes into the log file

value1

text string or number

any value

value2

text string or number

any value

...

...

...

Return value:

-

Example:

Array("Days","Mon","Tue","Wed","Thu","Fri","Sat","Sun")
WriteToLog("first = " + GetArray("Days",1))


Execution record of an example indicated above in the log file would look like as follows:


first = Mon

AddArray

Description:

Function adds another value to the end of the existing array with a particular name.

Call example:

AddArray(array name, value)

Input arguments:

Designation

Data type

Note

array name

text string

any text string; if a text string is not an argument, the error message writes into the log file

value

text string or value

any value

Return value:

-

Example:

a = Array("A")
AddArray("A","a")
AddArray("A","b")
WriteToLog("A = ("+GetArray("A",1)+","+GetArray("A",2)+")")


Execution record of an example indicated above in the log file would look like as follows:


A = (a,b)

GetArray

Description:

Function returns a value, which is saved in the array with a particular name, on a position set by requested index.

Call example:

GetArray(array name, index)

Input arguments:

Designation

Data type

Note

array name

text string

any text string; if a text string is not an argument, the error message writes into the log file


Attention! - array with a particular name must be already created

index

number

index of value location in the array, array elements are indexed from one.

Return value:

-

Example:

Array("Days","Mon","Tue","Wed","Thu","Fri","Sat","Sun")
WriteToLog("fifth = "+GetArray("Days",5))


Execution record of an example indicated above in the log file would look like as follows:


fifth = Fri

CountArray

Description:

Function returns a size of an array array name

Call example:

CountArray(array name)

Input arguments:

Designation

Data type

Note

array name

text string

any text string; if a text string is not an argument, the error message writes into the log file


Attention! - array with a particular name must be already created

Return value:

-

Example:

Array("Days","Mon","Tue","Wed","Thu","Fri","Sat","Sun")
WriteToLog("size = "+CountArray("Days"))


Execution record of an example indicated above in the log file would look like as follows:


size = 7

SetMem

Description:

Function creates a variable from a command, which is passed to the function in form of string. That can be an advantage, if you need to create variables on the basis of some parameter. Function practically does the same as if you write

variable name=value


Call example:

SetMem(variable name,value)

Input arguments:

Designation

Data type

Note

variable name

text string

any text string representing a variable name

value

text string or number.

any value

Return value:

-

Example:

Following example clarifies the function purpose:


SetMem("group" + 1,20)
WriteToLog("value = " + group1)


writes into the log file:


value = 20


This function is used quite frequently due to the following principle. We have a following input record:


2602 $aBasel :$bNatursforschende Gesellschaft
7001 $aBrodtbeck, Thomas.$4aut
7001 $aBrodtbeck, Thomas.$4aut


and following rules, where two rules lead to the same output record, and our aim is to create always new fields for both of the cases:


/*field 260*/
260I1->300I1 { WriteToLog("300 NF = " + NF) }
260$a->300$a { WriteToLog("300 NF = " + NF) }

/*field 700*/
700I1->300I1 { WriteToLog("700 NF = " + NF) }
700$a->300$a { WriteToLog("700 NF = " + NF) }


In this case the result would be as followed:


3001 $aBrodtbeck, Thomas
3001 $aBrodtbeck, Thomas


and the following would write into the log file:


300 NF = 1
300 NF = 1
700 NF = 1
700 NF = 1
700 NF = 2
700 NF = 2


But that is not what we want. Point is, that values variables NF,NS determine, to which output field index the result should be saved. As first field 700 has got index one, the final value writes to the 300 field with the index, and field 300, created at the conversion of 260 field, is overwritten.

Not even following construction would help us, that says, that a new field should always be created:


/*pole 260*/
260I1->300I1 { NF=0 }
260$a->300$a { NF=0 }

/*pole 700*/
700I1->300I1 { NF=0 }
700$a->300$a { NF=0 }


the result would then be:


3002 
300  $aBasel :
3001 
300  $aBrodtbeck, Thomas
3001
300  $aBrodtbeck, Thomas


The only right way is following:


/*field 260*/
260I1->300I1 { 
  SetMem("IF" + FROM_IDF + NF, MaxO("300")+1)
  NF=GetMem("IF" + FROM_IDF + NF) 
}
260$a->300$a { 
  NF=GetMem("IF" + FROM_IDF + NF)	
}

/*pole 700*/
700I1->300I1 {
  SetMem("IF" + FROM_IDF + NF, MaxO("300")+1)
  NF=GetMem("IF" + FROM_IDF + NF) 
}
700$a->300$a { 
  NF=GetMem("IF" + FROM_IDF + NF)
}


This complicated construction in the rule for the first indicator, which is definately performed first in the set of rules for 700 field, finds out through the function MaxO how many 300 fields already exist at the output. It will increase this value by one, and that's going to be an index, where this field will be converted to. It must remember this index, and must provide it to the other rules for this field. Variable name must be then unique for this field occurence, and therefore creates, through the use of SetMem function, an unique variable for each field (through variable FROM_IDF) The following variables would thus be created:

IF2601=1 
IF7001=2 
IF7002=3


and the result would look like as:


3002 $aBasel :
3001 $aBrodtbeck, Thomas.
3001 $aBrodtbeck, Thomas.


By using this SetMem function you should always use this construction, whenever you can't be sure, whether the field, where your field is directed to, is repeatable and can be created in another way than from the field, whose conversion you are just generating!




GetMem

Description:

Function returns a value preremembered by SetMem function and designated as variable name name.

Call example:

GetMem(variable name)

Input arguments:

Designation

Data type

Note

variable name

text string

any text string representing a variable name

Return value:

Variable value. Can be a number or a text string.

Example:

Read Help on function SetMem carefully.

IsSet

Description:

Function finds out if variable name variable exist.

Call example:

IsSet(variable name)

Input arguments:

Designation

Data type

Note

variable name

text string

any text string representing a variable name

Return value:

Number one, provided that a variable exists, otherwise it's zero.

Example:

Read Help on function SetMem carefully.

6. Functions for full record walking
MarcFieldsCount

Description:

According to the Source parameter value, function detects the number of the fields in the input or output record.

Note: Label is not considered as a field.

Call example:

MarcFieldsCount(source)

Input arguments:

Designation

Data type

Note

source

text string

Possible values

  • "I"

    It is input record

  • "O"

    It is output record

Return value:

Number indicating a number of the fields .

Example:

In this input record:


nam 2200229 a 4500
001  zpk20010038759
005  20010110000000.0
260  $aBasel :$bNatursforschende Gesellschaft
7001 $aBrodtbeck, Thomas.$4aut
7001 $aBrodtbeck, Thomas.$4aut


following command would:


Before->Before {
  WriteToLog("size input fields  = " + MarcFieldsCount("I"))
}


cause a write of the following text into the log file:


size input fields = 5

MarcGetFieldInfo

Description:

According to the Source parameter value, function returns a field information with Index Index in the input or output record.

Note: Label is not considered as a field.

Call example:

MarcGetFieldInfo(source, index, searched feature)

Input arguments:

Designation

Data type

Note

source

text string

Possible values

  • "I"

    It is input record

  • "O"

    It is output record

index

number

field sequence number, which you have in mind, counted from zero. The ceiling value can be detected through MarcFieldsCountfunction.

searched feature

text string

  • "ID" - field name

  • "I1" - first indicator

  • "I2" - second indicator

  • "CountSub" - field's subfield number

Return value:

Value including requested information.

Example:

In this input record:


nam 2200229 a 4500
001  zpk20010038759
005  20010110000000.0
260  $aBasel :$bNatursforschende Gesellschaft
7001 $aBrodtbeck, Thomas.$4aut
7001 $aBrodtbeck, Thomas.$4aut


following command would:


Before->Before {
    FCount = MarcFieldsCount("I")
    For i=0 To FCount-1
        WriteToLog("field = " + MarcGetFieldInfo("I",i,"ID"))
    Next
}


cause a write of the following text into the log file:


field = 001
field = 005
field = 260
field = 700
field = 700

MarcSetFieldInfo

Description:

According to the Source parameter value, function sets a field information with Index index in the input or output record.

Note: Label is not considered as a field.

Call example:

MarcSetFieldInfo(source, index, preset feature, value)

Input arguments:

Designation

Data type

Note

source

text string

Possible values

  • "I"

    It is input record

  • "O"

    It is output record

index

number

field sequence number, which you have in mind, counted from zero. The ceiling value can be detected through MarcFieldsCountfunction

preset feature

text string

  • "ID" - field name

  • "I1" - first indicator

  • "I2" - second indicator

value

text string

preset value

Return value:

-

Example:

In this output record:


nam 2200229 a 4500
001  zpk20010038759
005  20010110000000.0
260  $aBasel :$bNatursforschende Gesellschaft
7001 $aBrodtbeck, Thomas.$4aut
7001 $aBrodtbeck, Thomas.$4aut


following command would:


After->After {
    FCount = MarcFieldsCount("O")
    For i=0 To FCount-1
        MarcSetFieldInfo("O",i,"ID","111")
    Next
}


cause a following output record:


nam 2200229 a 4500
111  zpk20010038759
111  20010110000000.0
111  $aBasel :$bNatursforschende Gesellschaft
1111 $aBrodtbeck, Thomas.$4aut
1111 $aBrodtbeck, Thomas.$4aut

MarcGetSubFieldInfo

Description:

According to the Source parameter value, function returns a subfield information with subfield index Index to the appropriate field with field index index in the input or output record.

Note: Label is not considered as a field

Call example:

MarcGetSubFieldInfo(Source, field index, subfield index, searched feature)

Input arguments:

Designation

Data type

Note

source

text string

Possible values

  • "I"

    It is input record

  • "O"

    It is output record

field index

number

field sequence number, which you have in mind, counted from zero. The ceiling value can be detected through MarcFieldsCountfunction

subfield index

number

subfield sequence number, which you have in mind, counted from zero. The ceiling value can be detected through MarcGetFieldInfo function with "CountSub" parameter

searched feature

text string

  • "ID" - subfield name

  • "Value" - subfield value

  • "Index" - subfield index (value (NS)

  • "LinkingFieldID" - if subfield contains inserted field,function returns name of this field, otherwise empty string

  • "LinkingFieldI1" - if subfield contains inserted field,function returns first indicator of this field, otherwise empty string

  • "LinkingFieldI2" - if subfield contains inserted field,function returns second indicator of this field, otherwise empty string

  • "LinkingFieldCount" - number of subfields in the inserted field

Return value:

Value containing requested information.

Example:

In this input record:


nam 2200229 a 4500
001  zpk20010038759
005  20010110000000.0
260  $aBasel :$bNatursforschende Gesellschaft
7001 $aBrodtbeck, Thomas.$4aut
7001 $aBrodtbeck, Thomas.$4aut


following command would:


Before->Before {
    FCount = MarcFieldsCount("I")
    For i=0 To FCount-1
        IDF = MarcGetFieldInfo("I",i,"ID")
	SCount=MarcGetFieldInfo("I",i,"CountSub")
	For j=0 To SCount
          IDS = MarcGetSubFieldInfo("I",i,j,"ID")
	  WriteToLog("field=" + IDF + ";subfield=" + IDS)
        Next
    Next
}


cause a write of the following text into the log file:


field=001;subfield=E
field=005;subfield=E
field=260;subfield=a
field=260;subfield=b
field=700;subfield=a
field=700;subfield=4
field=700;subfield=a
field=700;subfield=4

MarcSetSubFieldInfo

Description:

According to the Source parameter value, function sets the subfield value with subfield index Index to the approptiate field with field index index in the input or output record.

Note: Label is not considered as a field

Call example:

MarcSetSubFieldInfo(source, field index, subfield index, searched feature, value)

Input arguments:

Designation

Data type

Poznámka

source

text string

Possible values

  • "I"

    It is input record

  • "O"

    It is output record

field index

number

field sequence number, which you have in mind, counted from zero. The ceiling value can be detected through MarcFieldsCountfunction

subfield index

number

subfield sequence number, which you have in mind, counted from zero. The ceiling value can be detected through MarcGetFieldInfo function with "CountSub" parameter

searched feature

text string

  • "ID" - subfield name

  • "Value" - subfield value

  • "LinkingFieldID" - if subfield contains inserted field,function returns name of this field, otherwise empty string

  • "LinkingFieldI1" - if subfield contains inserted field,function returns first indicator of this field, otherwise empty string

  • "LinkingFieldI2" - if subfield contains inserted field,function returns second indicator of this field, otherwise empty string

value

text string

preset value

Return value:

-

Example:

In this output record:


nam 2200229 a 4500
001  zpk20010038759
005  20010110000000.0
260  $aBasel :$bNatursforschende Gesellschaft
7001 $aBrodtbeck, Thomas.$4aut
7001 $aBrodtbeck, Thomas.$4aut


following command would:


After->After {
    FCount = MarcFieldsCount("O")
    For i=0 To FCount-1
        IDF = MarcGetFieldInfo("O",i,"ID")
	SCount=MarcGetFieldInfo("O",i,"CountSub")
	For j=0 To SCount
          MarcSetSubFieldInfo("O",i,j,"ID","x")
        Next
    Next
}


cause this output


nam 2200229 a 4500
001  $xzpk20010038759
005  $x20010110000000.0
260  $xBasel :$xNatursforschende Gesellschaft
7001 $xBrodtbeck, Thomas.$xaut
7001 $xBrodtbeck, Thomas.$xaut

MarcGetLinkingSubFieldInfo

Description:

According to the Source parameter value, function returns the inserted subfield information with inserted field subfield Index index subfield with subfield index index field with field Index index in the input or output record.

Note: Label is not considered as a field.

Call example:

MarcGetLinkingSubFieldInfo(source, field index, subfield index, inserted field subfield index, searched feature)

Input arguments:

Designation

Data type

Note

source

text string

Possible values

  • "I"

    It is input record

  • "O"

    It is output record

field index

number

field sequence number, which you have in mind, counted from zero. The ceiling value can be detected through MarcFieldsCountfunction

subfield index

number

subfield sequence number, which you have in mind, counted from zero. The ceiling value can be detected through MarcGetFieldInfo function with "CountSub" parameter

inserted field subfield Index

number

subfield sequence number, which you have in mind, counted from zero.

searched feature

text string

  • "ID" - subfield name

  • "Value" - subfield value

  • "Index" - subfield index

Return value:

value containing requested information

Example:

In this input record:


nam 2200229 a 4500
001  zpk20010038759
005  20010110000000.0
460  $120012$apodpole1$bpodpole2  
7001 $aBrodtbeck, Thomas.$4aut
7001 $aBrodtbeck, Thomas.$4aut


following command would:


Before->Before {
    FCount = MarcFieldsCount("I")
    For i=0 To FCount-1
	SCount=MarcGetFieldInfo("I",i,"CountSub")
	For j=0 To SCount
          LCount = MarcGetSubFieldInfo("I",i,j,
               "LinkingFieldCount")
	  If LCount > 0 Then
	    For k=0 To LCount
   	       IDL=MarcGetLinkingSubFieldInfo("I",i,j,k,"ID")
               WriteToLog("link=" + IDL)
	    Next
          Endif
        Next
    Next
}


cause a write of the following text into the log file:


link=a
link=b

MarcSetLinkingSubFieldInfo

Description:

According to the Source parameter value, function sets the value of inserted subfield with inserted field subfield Index index, subfield with subfield index index, field with field Index index in the input or output record.

Note: Label is not considered as a field

Call example:

MarcSetLinkingSubFieldInfo(source, field index, subfield index, inserted field subfield index, preset feature, value)

Input arguments:

Designation

Data type

Note

source

text string

Possible values

  • "I"

    It is input record

  • "O"

    It is output record

field index

number

field sequence number, which you have in mind, counted from zero. The ceiling value can be detected through MarcFieldsCountfunction

subfield index

number

subfield sequence number, which you have in mind, counted from zero. The ceiling value can be detected through MarcGetFieldInfo function with "CountSub" parameter

inserted field subfield index

number

subfield sequence number, which you have in mind, counted from zero

preset feature

text string

  • "ID" - subfield name

  • "Value" - subfield value

value

text string

preset value

Return value:

-

Example:

In this output record:


nam 2200229 a 4500
001  zpk20010038759
005  20010110000000.0
460  $120012$asubfield1$bsubfield2  
7001 $aBrodtbeck, Thomas.$4aut
7001 $aBrodtbeck, Thomas.$4aut


following command would:


After->After {
    FCount = MarcFieldsCount("O")
    For i=0 To FCount-1
	SCount=MarcGetFieldInfo("O",i,"CountSub")
	For j=0 To SCount
          LCount = MarcGetSubFieldInfo("O",i,j,
               "LinkingFieldCount")
	  If LCount > 0 Then
	    For k=0 To LCount
   	       MarcSetLinkingSubFieldInfo("I",i,j,k,"ID","x")
	    Next
          Endif
        Next
    Next
}

cause this result


nam 2200229 a 4500
001  zpk20010038759
005  20010110000000.0
460  $120012$xsubfield1$xsubfield2 
7001 $aBrodtbeck, Thomas.$4aut
7001 $aBrodtbeck, Thomas.$4aut

GetLabel

Description:

According to the Source parameter value, function returns a label value in form of a string either in the input or output record.

Call example:

GetLabel(source)

Input arguments:

Designation

Data type

Note

source

text string

Possible values

  • "I"

    It is input record

  • "O"

    It is output record

Return value:

Label value in form of a string

Example:

In this input record:


nam 2200229 a 4500
001  zpk20010038759
005  20010110000000.0
260  $aBasel :$bNatursforschende Gesellschaft
7001 $aBrodtbeck, Thomas.$4aut
7001 $aBrodtbeck, Thomas.$4aut


following command would:


Before->Before {
    WriteToLog("Label = " + GetLabel("I"))
}


cause a write of the following text into the log file:


Label = nam 2200229 a 4500

SetLabel

Description:

According to the source parameter value, function sets a label value in form of a string either in the input or output record. Value should be 24 characters long.

Call example:

SetLabel(source)

Input arguments:

Designation

Data type

Note

source

text string

Possible values

  • "I"

    It is input record

  • "O"

    It is output record

Return value:

-

Example:

In this output record:


-----nkm  22-----   450-
001  zpk20010038759
005  20010110000000.0
260  $aBasel :$bNatursforschende Gesellschaft
7001 $aBrodtbeck, Thomas.$4aut
7001 $aBrodtbeck, Thomas.$4aut


following command would:


After->After {
    SetLabel("O","-----akm  23-----   450-"))
}


cause a following output:


-----akm  23-----   450-
001  zpk20010038759
005  20010110000000.0
260  $aBasel :$bNatursforschende Gesellschaft
7001 $aBrodtbeck, Thomas.$4aut
7001 $aBrodtbeck, Thomas.$4aut

CopyField

Description:

Function creates a field copy with index index in the output record. Created copy includes subfield and inserted fields indicators.

Call example:

CopyField(index)

Input arguments:

Designation

Data type

Note

index

number

field sequence number, which you have in mind, counted from zero. The ceiling value can be detected through MarcFieldsCountfunction

Return value:

-

Example:

In this output record:


nam 2200229 a 4500
001  zpk20010038759
005  20010110000000.0
260  $aBasel :$bNatursforschende Gesellschaft
7001 $aBrodtbeck, Thomas.$4aut
7001 $aBrodtbeck, Thomas.$4aut


following command would:


After->After {
    FCount = MarcFieldsCount("I")
    For i=0 To FCount-1
        CopyField(i)
    Next
}


cause the output of:



nam 2200229 a 4500
001  zpk20010038759
005  20010110000000.0
260  $aBasel :$bNatursforschende Gesellschaft
7001 $aBrodtbeck, Thomas.$4aut
7001 $aBrodtbeck, Thomas.$4aut
001  zpk20010038759
005  20010110000000.0
260  $aBasel :$bNatursforschende Gesellschaft
7001 $aBrodtbeck, Thomas.$4aut
7001 $aBrodtbeck, Thomas.$4aut


SortSubfields

Description:

Function sorts either input or output field with field index (if need be with field name name)according to the rule rule.

Rule can for examle look like as follows: "[a,b,e,f](x,y,z)[1]". In this case, they are three sets of subfields indicators. Each set is closed in either brackets or parenthesis. If a set is closed in the brackets, that means, that the fields from the field being sorted, are selected in the result, and are kept in the same sequence as they were in the original field. If a set is closed in the parenthesis, that means, that hereby selected characters are additionaly sorted in accordance with a sequence indicated in the parenthesis.

Call example:

SortSubfields(source, field index or field name, rule)

Input arguments:

Designation

Data type

Note

source

text string

Possible values

  • "I"

    It is input record

  • "O"

    It is output record

field index or field name

number or text string

field sequence number, which you have in mind, counted from zero. The ceiling value can be detected through MarcFieldsCount function or field identificator (then the rule applies to all fields of this type)

rule

text string

sorting rule

Return value:

-

Example:

In such structured field of the input record:


$200 $b$a$y$1$2$e$f$x


following command would:


SortSubfields("I","200","[a,b,e,f](x,y,z)[1]")


cause this result

$200 $b$a$e$f$x$y$1$2


First, the fields from the set 1[a,b,e,f] were selected from the input, and were kept in the original sequence; then the fields from the set 2 (x,y,z) were selected from the input and were sorted in accordance with a sequence indicated in the rule; and then all elements from the set [1] were selected, and only then everything what was left there is indicated, which is subfield $2.

d) Table files


Table files serve for better overview of the rules set code. In case, there are many options, which some field or part of the field can take the form of, it is better to use table file in the conversion. Firstly, the table file has to be placed in the directory, which you set through TablesDirectory parameter in the configuration file. File can for example have a following form:


File 105_1.tbl

[105$a/1-4/->008/18-21/] - comment
a=a
b=b
c=c
d=d
e=e
f=f
g=g
h=h
i=i
j=j
k=k
l=l
m=m
n=a
o=p
y=
|=|


You can find the example of table application in the description of the function Table

Similar to the configuration file, all lines without = occurence are ignored in the table files, and also, as in the configuration file, it is possible to replace the characters by escape sequences.

7. Records control

If there is a control file path indicated in the ControlFile parameter in the configuration file, the record control will be run before conversion of each record. In case the control goes well, the conversion of the particular record sets off, in the oposite case it doesn't. You can read the result of the control in the log file, along with a control statistics of full package.

Control file manages to control:


  • Fields's repeatability, unrepeatability, necessity or unnecessity

  • Subfields 's repeatability, unrepeatability, necessity or unnecessity

  • Possible values on the indicators positions

  • Possible values on the positions in the position fields and subfields and their length


Control file example can look like as follows:


<LAB_><E_>/*[24](&,&,&,&,&,cdnop,abcdefgijklmr,amsci,
    S012,S,2,2,S,S,S,S,S,S123,Sin,S,4,5,0,S)*/
<001?>(S)(S)<E_>
<005?>(S)(S)<E_>
<010*>(S)(S)<a?><b?><d?><z*>
<011*>(S)(S)<a?><b?><d*><y*><z*>
<012*>(S)(S)<a?><b?><5?>
<013*>(S)(S)<a?><b?><d?><z*>


The primary priciple is, if a field, subfield or value aren't in the control file, and they occur in the record, then the convertor also considers them as an error.


The purpose of individual symbols in the control file:



a) Fields and subfields entity symbol

Description:

Symbol determines the field or subfield name, and defines possible number of these field or subfield occurences, in the valid record of the particular format.

Symbol:

<entity(occurence number symbol)>

Possible values

Designation

Data type

Note

entity

text string

it has to contain three characters designating the field name, which the control file applies to, or one character designating subfield name. This character can also be represented by character &, which designates any subfield. It is impossible to use this character in the field!

occurence number symbol

text string

single-character text string. Possible values are:

+ obligatory and repeatable

povinné a opakovatelné

_ obligatory and unrepeatable

povinné a neopakovatelné

* optional and repeatable

nepovinné a opakovatelné

? optional and unrepeatable

nepovinné a neopakovatelné

Notes:

Attention! - field control symbol must always be first in the line.

Attention! - if a field doesn't have a subfield, subfield E still has to be indicated. You can find more about it in the chapter Records access expressions.

Attention! - occurence number symbol must be single-character.


Example:

in such field in the input record:


2001 $aPrague$bgraphic$hVI$ufoto John Braun
2001 $aPrague$bgraphic$hVI$ufoto John Braun


following record in the control file would


<200?>(01)(S)<a+><b*><c*><d*><e*><f*><g*><h*><i*><v?><z*>


cause an error


#200$u#: Subfield 'u' in field '200' is not declared in control file
#200$u#: Subfield 'u' vin field '200' is not declared in control file
#200#: Field '200' is not repeatable


b) Value listing symbols in the indicator

Description:

Symbol indicates a listing of the values, that are possible in the indicator. Fields without the indicator are assumed to have a space character on both places.

Symbol:

(value listing)

Possible values

Designation

Data type

Note

value listing

text string

listing of the characters,that can occur in the particular indicator. Special value S indicates a space. Special value & indicates any value.

Notes:

Attention! - two indicator control symbols must always be first and second behind the field control symbol.

Example:

in such field in the input record:


200 4$aPrague$bgraphic$hVI


following record in the control file would


<200?>(01)(S)<a+><b*><c*><d*><e*><f*><g*><h*><i*><v?><z*>


cause an error


#200#: First indicator from field '200' contains invalid character
       (actual value: ' ' possible values: '01')
#200#: Second indicator from field '200' contains invalid character
       (actual value: '4' possible values: 'S')   


c) Value length symbols

Description:

Symbol indicates the obligatory subfield length. The length in the record must correspond to this, otherwise an error will be written into the log file.

Symbol:

[length]

Possible values

Designation

Data type

Note

length

number

number that indicates requested subfield length

Notes:

Attention! - symbol must directly come after the subfield symbol.

Example:

in such field in the input record:


102  $aCZZ


following record in the control file would


<102?>(S)(S)<a*>[2]<b*>[2]


cause an error


#102$a#: Subfield 'a'contains invalid size
         (actual size: '3' required size: '2') in field '102' 


d) Value listing symbol in the subfield positions

Description:

Symbol indicates a listing of the values, that are possible in the particular position, each position is separated by comma. Value length symbols ([length]) must though precede to this listing, and number of the separated listings must correspond with a number that Value lenght symbols indicate.

Symbol:

(value listing,value listing....)

Possible values

Designation

Data type

Note

value listing

text string

listing of the values, that can occur in the particular indicator. Special value S indicates a space. Special value & indicates any value.

Notes:

Attention! - two indicator control symbols must always be first and second behind the field control symbol.

Example:

in such field in the input record:


106  $ax


following record in the control file would


<106?>(S)(S)<a_>[1](defghijrz)


cause an error


e) Inserted fields symbols

Description:

Symbol indicates the rules for the field's inserted subfields.

Symbol:

{expression for whole field}

Possible values

Designation

Data type

Note

expression for whole field

group of symbols

field's complete control rule must occur in the inserted field expression. That means field, its indicators and its subfields ...

Notes:

Attention! - symbol must come immediately after the subfield symbol, where the subfield is inserted, which in most cases in the unimarc is <1*>

Example:

in such field in the input record:


410 0$1200  $jDocumenta Pragensia


following record in the control file would


<423*>(S9)(01)<a?><h?><i?><m?><1*>{
    <200_>(01)(S)<a_><b*><c*><d*><e*><f*><g*>
                          <h*><i*><v?><z*><5?>}


cause an error


LINKING#200#:  First indicator from field '200' contains 
     invalid character (actual value: ' ' possible values: '01')
LINKING#200$a#:Subfield 'a' is mandatory in field '200'
LINKING#200$j#:Subfield 'j' in field '200' is not declared 
		in control file



f) Detailed control

Even after the control through the control file, you can still do the detailed control through the rules, that can affect any dependancies in the record. If your rule finds an error, use ContinueError function in order to print a message into the log file and to mark the record as faulty. This way the execution of the other rules won't be interrupted. Example of the control rule file would look like as follows:


Before->Before
{
   WriteToLog("Detailed verification");
   WriteToLog("=====================");  
}

102$a->All
{
   SO=Table("Country_Code.tbl",S)
   If SO=="XX" Then 
       If Language=="CZE" Then
          ContinueError("#DET_" + FROMC + "# Neznámý kód země " + S)
       Else
          ContinueError("#DET_" + FROMC + "# Unknown country code " + S)
       Endif   
   Endif    
   SET=0
}


When creating the control rules, please bear in mind:


  • Rules follow the usual method, which means, that they strive to create some record at the output. Your rules should have then a key word All as the output, and should by all means be ended by a command SET=0, in order to prevent a convertor to report an error.

  • Even at the process of the control, using the control rules, the output file is created DestinationFile , however, in this case it doesn't have any meaning. It does have one, if you use the control file and at the same time you convert through the rules, but if the rules apply only to the detailed control, no meaningful output is created.



8. Plugins


Plugins bring other functions to the convertor's scope, these would be difficult or impossible to realize through the usescript language standard resources. Plugins are implemented in a form of shared libraries (files with .dll suffix in MS Windows environment, and files with .so suffix in unix environment), therefore it is possible to add plugins without a necessity to install a new program version.


a) Installation


Plugin installation consists of the following steps:


  • downloading and saving of the shared library for a particular platform into the suitable directory (in typical case $MARCMAN_HOME/plugins)

  • shared library path specification in the convertor's configuration file (method of shared library path specification is described in the chapter concerning the convertor's configuration parameters - see PluginsDirectory and Plugins parameters)

  • installation of the files requested by a particular plugin in accordance with Installation requirements indicated in its description (see e.g. plugin unicode)

  • convertor's re-initiation (it is useful to examine the convertor's log file after the convertor's re-initiation, and be assured, that a plugin was initiated successfully and that it is functional)


b) Plugin md5

Description


Plugin name:

md5

Shared library name :

plugin_md5.so / plugin_md5.dll

Description:

Plugin broadens the convertor's functionality by a possibility of so called MD5 hash calculation. MD5 hash is hexadecimal string with a fixed length (32 characters), calculated from given input string of any length. MD5 hash's primary characteristics is, that a probability, that MD5 hash will be a result for two different input strings, is relatively small. With regard to the MD5 hash features, which is, it is a hexadecimal string 32 characters long, there is certainly a set of input data, where MD5hash is the same, but in case of the "reasonable" input data, such as e.g a text in the natural language, these cases don't occur .

Installation requirements:

-

Functions provided

ComputeHash

Description:

Function calculates the MD5 hash from given input text string.

Call example:

md5.ComputeHash(text)

Input arguments:

Designation

Data type

Note

text

text string

any text string; if a text string is not an argument, error message writes into the log file

Return value:

Return value is a calculated MD5 hash from given text string

Example:

t = md5.ComputeHash("test")
WriteToLog("MD5 hash = "+t)


Record of executed example indicated above in the log file would look like as follows:


MD5 hash = 098f6bcd4621d373cade4e832627b4f6


c) Plugin unicode

Description


Plugin name:

unicode

Shared library name:

plugin_unicode.so / plugin_unicode.dll

Description:

Plugin broadens the convertor' functionality by a possibility of removing the diacritics from the text inscribed in UTF-8 coding. An assumption though is, that the input text is already in this coding , plugin doesn't support the conversion among different character sets.

Installation requirements:

File including the definitions of the compound UTF-8 characters breakdown into the basic elements must be placed in the directory specified by the convertor's parameter TablesDirectory . File must be named as UnocodeData.txt, and its current version can be downloaded from: http://www.unicode.org/Public/UNIDATA/UnicodeData.txt.

Functions provided



Utf8ToAscii

Description:

Function transfers, breaks down a given input text string into the basic elements in UTF-8 coding, and keeps only the ones belonging to the ASCII character set.

Call example:

unicode.Utf8ToAscii(text)

Input arguments:

Designation

Data type

Note

text

text string

any text string; if a text string is not an argument, error message writes into the log file

Return value:

Return value is a given input text string transferred to ASCII character set.