<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none"><!-- p { margin-top: 0px; margin-bottom: 0px; }--></style>
</head>
<body dir="ltr" style="font-size:12pt;color:#000000;background-color:#FFFFFF;font-family:Calibri,Arial,Helvetica,sans-serif;">
<p>Alas there is currently no way to create your own named functions using only the Fix language (but there are some idea how this could be done). Alas, you need to copy and paste code for now.<br>
</p>
<p><br>
</p>
<p>The main use case was to transform MARC to something else ;). But there is more and more support to change MARC itself.  This needs to be cleaned up in the near future.<br>
</p>
<p><br>
</p>
<p>marc_add does have the functionality you can add values to a separate record field:<br>
</p>
<p><br>
</p>
<p><code class="perl plain" style="font-size: 12px; background-color: rgb(245, 245, 245); white-space: pre; box-sizing: content-box !important; font-family: inherit !important; padding: 0px !important; border-radius: 0px !important; background-image: none !important; background-position: initial !important; background-size: initial !important; background-repeat: initial !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: normal !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; min-height: auto !important;">marc_add(</code><code class="perl string" style="font-size: 12px; background-color: rgb(245, 245, 245); white-space: pre; box-sizing: content-box !important; font-family: inherit !important; padding: 0px !important; color: blue !important; border-radius: 0px !important; background-image: none !important; background-position: initial !important; background-size: initial !important; background-repeat: initial !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: normal !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; min-height: auto !important;">'900'</code><code class="perl plain" style="font-size: 12px; background-color: rgb(245, 245, 245); white-space: pre; box-sizing: content-box !important; font-family: inherit !important; padding: 0px !important; border-radius: 0px !important; background-image: none !important; background-position: initial !important; background-size: initial !important; background-repeat: initial !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: normal !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; min-height: auto !important;">,
 ind1 , </code><code class="perl string" style="font-size: 12px; background-color: rgb(245, 245, 245); white-space: pre; box-sizing: content-box !important; font-family: inherit !important; padding: 0px !important; color: blue !important; border-radius: 0px !important; background-image: none !important; background-position: initial !important; background-size: initial !important; background-repeat: initial !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: normal !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; min-height: auto !important;">'
 '</code><span style="color: rgb(51, 51, 51); font-family: Menlo, Monaco, "DejaVu Sans Mono", Consolas, "Bitstream Vera Sans Mono", Courier, "Courier New", monospace; font-size: 12px; white-space: pre; background-color: rgb(245, 245, 245);">
</span><code class="perl plain" style="font-size: 12px; background-color: rgb(245, 245, 245); white-space: pre; box-sizing: content-box !important; font-family: inherit !important; padding: 0px !important; border-radius: 0px !important; background-image: none !important; background-position: initial !important; background-size: initial !important; background-repeat: initial !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: normal !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; min-height: auto !important;">,
 a, </code><code class="perl string" style="font-size: 12px; background-color: rgb(245, 245, 245); white-space: pre; box-sizing: content-box !important; font-family: inherit !important; padding: 0px !important; color: blue !important; border-radius: 0px !important; background-image: none !important; background-position: initial !important; background-size: initial !important; background-repeat: initial !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: normal !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; min-height: auto !important;">'test'</code><span style="color: rgb(51, 51, 51); font-family: Menlo, Monaco, "DejaVu Sans Mono", Consolas, "Bitstream Vera Sans Mono", Courier, "Courier New", monospace; font-size: 12px; white-space: pre; background-color: rgb(245, 245, 245);">
</span><code class="perl plain" style="font-size: 12px; background-color: rgb(245, 245, 245); white-space: pre; box-sizing: content-box !important; font-family: inherit !important; padding: 0px !important; border-radius: 0px !important; background-image: none !important; background-position: initial !important; background-size: initial !important; background-repeat: initial !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: normal !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; min-height: auto !important;">,
</code><code class="perl string" style="font-size: 12px; background-color: rgb(245, 245, 245); white-space: pre; box-sizing: content-box !important; font-family: inherit !important; padding: 0px !important; color: blue !important; border-radius: 0px !important; background-image: none !important; background-position: initial !important; background-size: initial !important; background-repeat: initial !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: normal !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; min-height: auto !important;">'b'</code><code class="perl plain" style="font-size: 12px; background-color: rgb(245, 245, 245); white-space: pre; box-sizing: content-box !important; font-family: inherit !important; padding: 0px !important; border-radius: 0px !important; background-image: none !important; background-position: initial !important; background-size: initial !important; background-repeat: initial !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: normal !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; min-height: auto !important;">,
 test , record:record2)</code><br>
</p>
<p><br>
</p>
<p>Alas I didn't add it to the marc_set, marc_remove and marc_replace_all fixes.<br>
</p>
<p><br>
</p>
<p>It is quite comming in Fix to extract fields out of the MARC in temporary fields. If you only export to MARC, then these temporary fields are ignored. The MARC exporters only look at the 'record' field.<br>
</p>
<p><br>
</p>
<p>To log or export fields in a stream processing I would suggest to look at the add_to_exporter fix:<br>
</p>
<p><br>
</p>
<p><a href="https://metacpan.org/pod/release/NICS/Catmandu-1.0602/lib/Catmandu/Fix/add_to_exporter.pm">https://metacpan.org/pod/release/NICS/Catmandu-1.0602/lib/Catmandu/Fix/add_to_exporter.pm</a>​<br>
</p>
<p><br>
</p>
<p>Cheers<br>
</p>
<p>Patrick<br>
</p>
<div style="color: rgb(33, 33, 33);">
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>From:</b> Uldis Bojars <captsolo@gmail.com><br>
<b>Sent:</b> Thursday, June 29, 2017 3:49 PM<br>
<b>To:</b> Patrick Hochstenbach<br>
<b>Cc:</b> librecat-dev@lists.uni-bielefeld.de<br>
<b>Subject:</b> Re: [librecat-dev] string operations, defining functions in Catmandu</font>
<div> </div>
</div>
<div>
<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>
</div>
</div>
</body>
</html>