|
| 1 | +--- |
| 2 | +title: Manipulating fields using the PROC command |
| 3 | +description: Guide to the interactive PRC conversion interface and advanced technical reference for record manipulation using the MX proc command. |
| 4 | +--- |
| 5 | + |
| 6 | +# Manipulating fields using the PROC command |
| 7 | + |
| 8 | +ABCD and its underlying technology (CISIS) allow for extremely powerful data manipulation through formatting files and processing scripts (`.prc`). By using the `mx` utility and the `proc` function, it is possible to completely restructure the records of a database. |
| 9 | + |
| 10 | +This page documents the **Interactive Conversion Interface** (which automates the application of PRC scripts) and provides the **Advanced Technical Reference** for building conversion rules and structuring MARC databases. |
| 11 | + |
| 12 | +--- |
| 13 | + |
| 14 | +## 1. Interactive PRC Conversion Interface |
| 15 | + |
| 16 | +Historically, massive data conversion (for example, after importing a delimited TXT or CSV file) required executing `mx` commands in the operating system's command line. |
| 17 | + |
| 18 | +To streamline this workflow, ABCD provides an interactive post-migration web conversion interface. This tool allows database managers to test and apply conversion scripts visually and safely. |
| 19 | +To access this, select a database from the home screen and click on **Utilities > Export/import > Modifying a record using the PROC command**. |
| 20 | + |
| 21 | + |
| 22 | +### How to Use the Interface |
| 23 | + |
| 24 | +The process is divided into three guided steps: |
| 25 | + |
| 26 | +1. **Write the Conversion Script (PRC Rules):** |
| 27 | + * In the text editor box, enter the formatting language (PFT) rules that will dictate the modifications to the records. |
| 28 | + * The typed script is automatically saved to the `fix.prc` file within the database's data directory. |
| 29 | + |
| 30 | + |
| 31 | + |
| 32 | + |
| 33 | +2. **Run and Preview (Homologation):** |
| 34 | + * Clicking the preview button does not alter your main database. Instead, it generates a temporary database (e.g., `rda_v1`). |
| 35 | + * The interface processes the **first 5 records** and displays them side-by-side in the Preview section: |
| 36 | + * **BEFORE (Original):** The record as it currently exists in the database. |
| 37 | + * **AFTER (Converted):** How the record will look after the script is applied. |
| 38 | + * This environment ensures that tags, subfields, and fixed positions are mapped correctly before affecting the entire collection. |
| 39 | + |
| 40 | +  |
| 41 | + |
| 42 | +3. **Commit Conversion:** |
| 43 | + * If the preview results are correct, the manager clicks **Commit Conversion to Main Database**. |
| 44 | + * **Safety:** The system automatically creates a backup of the original database (creating the `_ori.mst` and `_ori.xrf` files) and replaces the main files with the converted version. |
| 45 | + |
| 46 | +--- |
| 47 | + |
| 48 | +## 2. Technical Reference: The `proc` Command and `fldupdat()` |
| 49 | + |
| 50 | +The logic used in conversion scripts relies heavily on the `proc` function. The `proc` parameter allows you to specify, through a PFT format, modifications to be performed on the fields of the source record. |
| 51 | + |
| 52 | +**Fundamental Concept:** Modifications are not made directly to the source database, but rather in memory or in the destination database. If a destination database is not specified, the changes might be seen on the screen but will be lost after execution. |
| 53 | + |
| 54 | +### Limits and Recursion |
| 55 | +* It is possible to specify up to **1024 `proc=` parameters** in a single MX command line. |
| 56 | +* Each successive `proc` will act upon the record in its current state; meaning, if a previous `proc` modified the record, the next one will process the resulting data from that modification. |
| 57 | +* A `proc` can be included inside another `proc` (recursive calls) without limits. |
| 58 | + |
| 59 | +### Basic `fldupdat()` Syntax |
| 60 | + |
| 61 | +Below are the commands natively accepted by the function governing `proc`: |
| 62 | + |
| 63 | +| Command | Description | Example | |
| 64 | +| :--- | :--- | :--- | |
| 65 | +| **`d.`** | Logically deletes the record. | `proc='d.'` | |
| 66 | +| **`d*`** | Deletes **all** fields in the record. | `proc='d*'` | |
| 67 | +| **`dtt`** | Deletes all occurrences of the specified tag `tt` (e.g., Tag 26). | `proc='d26'` | |
| 68 | +| **`dtt/occ`** | Deletes only a specific occurrence `occ` of the tag `tt`. | `proc='d26/3'` | |
| 69 | +| **`att#str#`** | Adds the string `str` as a new occurrence of tag `tt`. The separator `#` can be any non-numeric character as long as it does not occur in the inserted data. | `proc='a999#cds#'` | |
| 70 | +| **`htt n str_n`** | Adds the string `str_n` of length `n` (in bytes) to tag `tt`. | `proc='h99 8 CDS/ISIS'` | |
| 71 | +| **`=<mfn>`** | Replaces the record number (MFN) with a new value `n`. | `proc='=10'` | |
| 72 | +| **`s<tag>`** | Sorts the record's directory entries by the numeric tag. | `proc='s' proc='s70'` | |
| 73 | + |
| 74 | +#### ⚠️ Golden Rules of `proc` |
| 75 | +1. Within the same `proc` parameter, **all delete commands (`d`) must precede the add commands (`a`, `h`, etc.)**. |
| 76 | +2. Do not use two or more delete commands by occurrence (`dtt/occ`) for the same field in the same call. |
| 77 | +3. The `=` command (MFN substitution) and the `s` command should not be mixed with other commands in the same `proc`. |
| 78 | + |
| 79 | +### Advanced Functions and Integrations |
| 80 | + |
| 81 | +For complex migrations, CISIS offers extended syntaxes and database integration functions: |
| 82 | + |
| 83 | +* **`<TAG>data</TAG>`**: Adds `data` as a new occurrence of the `TAG` field. This function allows the use of parameters to remove markup lengths (`stripmarklen`) and impose minimum lengths (`minlen`). |
| 84 | +* **`x[append=]<mf>`**: Writes the data of the current record into the specified master file `<mf>`. |
| 85 | +* **`r<mf>,<mfn>`**: Looks up the corresponding `<mfn>` in another database (`<mf>`) and includes its fields in the active record. |
| 86 | +* **`g<gizmo_mf>[,<taglist>]`**: Applies a replacement database (Gizmo) over the record or over a specific list of tags. |
| 87 | +* **`gsplit[/clean]=<tag>[=<criterion>]`**: Extracts and partitions fields into new occurrences based on separators (`char`), words (`words`), letters, numbers, or trigrams. |
| 88 | +* **`gload` / `gdump`**: Used to load or extract binary files into/from a specific tag. |
| 89 | + |
| 90 | +--- |
| 91 | + |
| 92 | +## 3. Practical Model: Building a Generic MARC Leader |
| 93 | + |
| 94 | +By utilizing PFT conditional statements combined with the XML-style inclusion concept (`<TAG>data</TAG>`) understood by MX, it is possible to create advanced logic to migrate local fields to the **MARC 21** standard. |
| 95 | + |
| 96 | +The practical script below illustrates the deletion of old fields (like `90`, `264`, `980`), the conditional inclusion of formatted variables, and the manual structuring of a generic Leader (Fixed Field 008) for migrated works. |
| 97 | + |
| 98 | +```pft |
| 99 | +'d90','d264','d980', |
| 100 | +if p(v5) then '<3005>', v5 ,'</3005>' else '<3005>n</3005>', fi, |
| 101 | +if p(v6) then '<3006>', v6 ,'</3006>' else '<3006>a</3006>' fi, |
| 102 | +'<3007>m</3007>', |
| 103 | +'<3008>0</3008>', |
| 104 | +'<3017>5</3017>', |
| 105 | +'<3018>a</3018>', |
| 106 | +'<3019>0</3019>', |
| 107 | +'<8>260321s bl # #rbl ##opr # # #u</8>', |
| 108 | +if p(v90^a) then '<90>^a', v90^a' ^b'v90[2]^b ,'</90>' fi, |
| 109 | +if p(v264^a) then '<264>^a', v264^a' ^b'v264^b ,'</264>' fi, |
| 110 | +if p(v980) then '<980>^o', v980^o' ^d'v980^d ,'</980>' fi, |
| 111 | +``` |
| 112 | + |
| 113 | +**Structure Analysis:** |
| 114 | +1. **Deletion Priority:** The instructions `'d90','d264','d980'` open the script, ensuring that the raw original data does not collide with the organized recreation of the tags. |
| 115 | +2. **Fixed Definitions (`<8>`):** In tag `<8>`, the fixed-length field is assembled following the MARC guide for Dates, Country of publication (`bl`), Language, and Cataloging source. Placeholders and literals (like `s` for single date) are mapped in plain text. |
| 116 | +3. **Conditional Mapping (`if p()`):** The script evaluates the existence of the variable; if it exists, the instruction wraps the complete tag with proper subfield formatting (e.g., `^a` and `^b`), while also respecting occurrences through array indices (e.g., `v90[2]^b`). |
| 117 | + |
| 118 | +--- |
| 119 | + |
| 120 | +## 4. The XML `<proc>` Element |
| 121 | + |
| 122 | +Beyond being used directly via scripts passed to `mx` in the conversion utility, the `proc` command can be invoked natively by ABCD in XML-structured architectures. |
| 123 | + |
| 124 | +The `<proc>` element allows you to modify the content of the record currently loaded in memory, subjecting it to ISIS Formatting Language (PFT) rules. |
| 125 | + |
| 126 | +Unlike the `<display>` element, which sends the output directly to the screen (browser) or a file, the `<proc>` element executes the PFT blindly and applies the results **internally** to the record's fields. |
| 127 | + |
| 128 | +### XML Usage Rules |
| 129 | +* **Allowed content:** The element must exclusively enclose `<pft>` tags. |
| 130 | +* **Parent Elements:** `<do>`, `<function>`, `<hl>`, `<loop>`, `<section>`, `<update>`. |
| 131 | + |
| 132 | +### XML Syntax and Example |
| 133 | + |
| 134 | +Below is how the XML environment wraps the same formatting seen in `fix.prc` scripts: |
| 135 | + |
| 136 | +```xml |
| 137 | +<proc> |
| 138 | + <pft>PFT_INSTRUCTIONS_HERE</pft> |
| 139 | +</proc> |
| 140 | +``` |
| 141 | + |
| 142 | +In this example, the script processed by the XML deletes the original `2024` field and restructures its value by attaching a prefix 'a' and concatenating the content of field `2027` at the end, separated by `~`: |
| 143 | + |
| 144 | +```xml |
| 145 | +<proc> |
| 146 | + <pft> |
| 147 | + 'd2024', |
| 148 | + 'a2024~', v2024, '~', v2027, '~' |
| 149 | + </pft> |
| 150 | +</proc> |
| 151 | +``` |
0 commit comments