I posted a small update to MarcEdit last night (or this morning depending on your perspective). Changes were as follows:
** Bug Fix: Custom Swap Field Function — corrected an error that would cause the targeted field to be sorted out of order.
** Bug Fix: Replace All (RegEx) — Corrected a bug that caused non-matching regular expression items to drop data when using the /m switch for matching multiple data fields.
** Enhancement: Generate Control Numbers: Added the ability to set the field for the control number to be inserted. Can be added to an existing field, be added as a repeatable field, or added as a control field.
** Enhancement: Added Swap Title function to the Edit Shortcuts section.
** Enhancement: When splitting data, the program will increment file names if like control numbers exist in a file (i.e., two records with the same control number will result in a file called "controlnumber.mrc" and controlnumber1.mrc"
The two most noticeable changes are with the Generate Control Numbers function and the Swap Title Function.
Generate Control Numbers
The generate control numbers function has always been a part of the application – but has always been limited to created control number data in the 001 field. Likewise, there was a limitation that only allowed data to be generated if an 001 wasn’t present. The update makes the following changes:
- Ability to set the Field or Field/Subfield combination for the data to be inserted.
- An option to always insert (allowing for control numbers to be generated if the field or field/subfield combination already exists in a file. This would be good for adding new control numbers to repeatable fields, like the 035.
Swap Title Data
This request came up a week or two ago. The question was related to swapping data in the 245$a into the 776$t. MarcEdit has always included a swap field function which works if the user wants to move all the data in the $a into the new field/subfield pair. However, in this case, the user wanted to move the title data without the non-filing characters. The current swap field function does not support that option.
In considering how to make this change, I ran into a problem – the swap field function is one of the oldest functions in the MarcEdit toolbox and the code is showing its age. It’s also quite complicated, because of the many different types of options available to it. Originally, I’d planned on just adding to this master function – but the complexity involved in updating the function became too unweldy.
One of the dangers of working on a large project for so long, is that bits of old code that no longer are used tend to take up life as part of the coded, undead. Zombie bytes that simply take up compiler space and occasionally screw with your mind when it rises back to life do to a missed case statement or commented line of code. While working with the swap field function, it also became apparent that I need to refactor the present function (something I’m starting). This happens all the time. Whenever I do significant work on an area of the program, I take that as an opportunity to refactor old code. In fact, not too long ago, I streamlined all the code in the primary editing library – except the swap field function. It kind of looks like code that was written by two monkeys pounding on a keyboard. It’s long (somewhere between 10-15,000 lines of code), redundant in parts, and ugly. Yet, it works and works well and in the real world, working code wins. And yet, I’ve started the refactoring process because it’s time for this function to go on a diet….
**off Side Note**
In the end, what I decided to do was add this as a macro of sorts. In the last update, I added a new section called Edit Shortcuts. These are shortcuts to what are actually complex regular expressions that no person should ever have to work out. So I added it here. The tool expects that data will be extracted from the 245$a, and the user determines what field and subfield they will place the data into. This is a first pass on the macro, I’ll be updating it soon to allow indicator values to be added as well as part of the field creation process.
To use it, look in the MarcEditor under Edit/Edit ShortCuts/Field Edits/Title Swap.