Patron script

<< Click to Display Table of Contents >>

Navigation:  Scripting >

Patron script

Previous pageReturn to chapter overviewNext page

Librid 3 supports modifying patron code in a script, before sending it to the library system. This allows for example removing pre- and suffix characters from patron codes, and excluding unwanted codes.

Patron code script is in a file named CardScript.cs. It is a C# script for .NET framework 4.0 .

To enable Patron script, turn on setting Use script for patron code in Management Utility.

The Namespace must be CardScript , the class name must be ScriptCardConverter and the method that is called by Librid is Convert . The method has two overloaded versions:

 

 public string Convert(string text)

 public string Convert(string text, int info)

 

The latter one has an extra parameter info and is only called if the parameter Use parameter for patron card script is selected. In such case, the info parameter has a flag to indicate where the patron identifier is from:

 

 info == 0: patron identifier comes from the barcode or RFID reader

 info == 1: patron identifier comes from the on-screen keyboard

 

Thus, the whole script file could look as follows to add a "S" in front of a patron identifier when it comes from the screen keyboard, and "R" when it comes from the barcode or RFID reader:

 

using System;

 

namespace CardScript

{

    public class ScriptCardConverter

    {

        public string Convert(string text)

        {

            return Convert(text, 0);

        }

 

        public string Convert(string text, int info)

        {

            if (info == 0)

                return "R" + text;

            else if (info == 1)

                return "S" + text;

            else

                return "Error - this should be impossible";

        }

    }

}

 

The first Convert method simply calls the second one with parameter info set to "0", because it doesn't know what else to do.