<div dir="ltr">On 29 June 2017 at 14:28, Patrick Hochstenbach <span dir="ltr"><<a href="mailto:Patrick.Hochstenbach@ugent.be" target="_blank">Patrick.Hochstenbach@ugent.be</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><br>
But while waiting for this new feature you can use a dirty trick to get the required result. The Fix script below will add the 100 subfields to the 400 field and adds a<br>
period “.” when required:<br>
<br>[...]<br>
<br>
The trick is the append(record.$last.$last,".”) line which knows that MARC is modeled as an array of arrays in Catmandu and adds a period to the last element.<br></blockquote><div><br></div><div>Thanks! This trick + "marc_match(100aqbcd,"\.$")" saves the day :) </div><div><br></div><div>What if I need to reuse the result [ = the new field 400aqbcd with "." at the end ] multiple times (e.g. to create multiple 400 fields with more subfields added, different in each case)?</div><div><br></div><div>Is there a way to copy the full structure (with subfields) of a MARC field into a temporary field / variable and then create a new MARC field based on it?</div><div>  - another option is to hold this temporary value in a non-standard MARC field (e.g. "XYZ") but that feels like a hack</div><div><br></div><div>P.S. Is there a way to dump / log contents of a field (variable) from the Fix script?<br></div><div><br></div><div>Uldis</div><div><br></div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">> On 28 Jun 2017, at 18:41, Uldis Bojars <<a href="mailto:captsolo@gmail.com">captsolo@gmail.com</a>> wrote:<br><div><div class="gmail-h5">
><br>
> Hi,<br>
><br>
> Could you suggest how to do this in Catmandu:<br>
><br>
> I need to form a new MARC field ("400") that consist of some subfields (in this order: $a $q $b $c $d) of an existing field ("100"). That much is not difficult, but there's another condition:<br>
><br>
> "." must be added to the last subfield that exists (e.g. if $d exists append "." to it unless it already ends with ".", otherwise do the same with $c, [...]) .<br>
><br>
> Questions:<br>
><br>
> 1) how to determine if a field (e.g. fld_100d created via marc_map) ends with "." ?<br>
><br>
> 2) is there a way to "package" some functionality and call it when needed?<br>
><br>
> In this case it would be good to create a function that appends "." to the field provided as a parameter unless it already ends with ".".<br>
><br>
> Then what is needed could be achieved like this:<br>
><br>
> if exists("fld_100d"):<br>
>    my_function("fld_100d")<br>
> elsif exists("fld_100c"):<br>
>    my_function("fld_100c")<br>
> elsif [...]<br>
>    [...]<br>
> end<br>
><br>
> P.S. Perhaps there is a more idiomatic way how to do this in Catmandu?<br>
><br>
> Thanks,<br>
> Uldis<br>
><br>
</div></div>> ______________________________<wbr>_________________<br>
> librecat-dev mailing list<br>
> - send list mails to <a href="mailto:librecat-dev@lists.uni-bielefeld.de">librecat-dev@lists.uni-<wbr>bielefeld.de</a><br>
> - to unsubscribe or change options, visit <a href="https://lists.uni-bielefeld.de/mailman2/cgi/unibi/listinfo/librecat-dev" rel="noreferrer" target="_blank">https://lists.uni-bielefeld.<wbr>de/mailman2/cgi/unibi/<wbr>listinfo/librecat-dev</a><br>
> - project website: <a href="http://librecat.org/" rel="noreferrer" target="_blank">http://librecat.org/</a><br>
<br>
</blockquote></div><br></div></div>