Codes Syntax

From Opera Wiki

Jump to: navigation, search
Note N.B: The code syntax function was created for the purpose of creating restrictions or, more generally, rules to be used on the names of articles in the archive. Such rules may be used, for example, to force the use of a minimum or maximum number of characters, a subset of characters, or prohibit others.


Contents


Some Basics

Creating a syntax rule involves a basic knowledge of regular expressions: a regular expression is a sequence of symbols that identifies a set of strings. Each symbol has a well-defined meaning, e.g:

  • The symbol ^: identifies the beginning of the string.
  • The symbol *: quantifier (between 0 and n times).
  • [a-z]: identifies lowercase letters between a and z.
  • [0-9]: identifies numbers between 0 and 9.
  • The symbol $: identifies the end of the string.

An example of a regular expression could be: ^60TT-[a-z]*-ALL$, which identifies all strings that begin with the characters 60TT-, have any number of lowercase letters and end with the substring -ALL.

Given the breadth of the subject, this chapter will not cover all the rules and syntax of regular expressions, but please refer to the online bibliography for further details.


Content Description

La finestra della Sintassi dei codici


  • Type/System/Series: filter fields to identify the system, series and type of article to which the code has been applied.
  • Test: field for checking and filtering the codes matched to the articles.
  • Name: name of the syntax.
  • Desc: description of the syntax.
  • Tipo/Sistema/Serie File:menutendina.png: fields for choosing the system, series and type of article to which the syntax is to be matched.
  • Syntax: field for recording the regular expression.
  • Force Syntax: if activated, does not allow the registration of the expression if the syntax is not respected.
  • Test: fields for testing the validity of the syntax.




How to create a Code Syntax

Let’s try using this regular expression as an example to create a Code Syntax in the programme:

  • We open the archive and create a new entry by assigning a name and a description
  • We open the archive and create a new entry by assigning a name and a description
  • We write the chosen rule in the syntax field, for example abcde or 60TT-123-ALL.

We then activate the Force syntax field to make the programme prohibit the entry from being registered in the archive if the syntax rule is not respected.

As you can see, the bottom section provides a series of fields in which you can test the syntax on any string.

If the string does not pass the conformity check, an error symbol will appear next to the text; conversely, a confirmation symbol will appear.


Use in the program

  • In the profile archive, create a new profile for the system and series selected in the Code Syntax frame and paste the text abcde in the Name field.


  • The program will not allow the new profile to be saved because the code entered does not comply.


If, instead we use the code 60TT-abcd-ALL, the new profile can be registered.


File:Inserimentocodice.png File:Inserimentocodice2.png
Personal tools